UITabBar images visible on simulator, disappear on the device

我是研究僧i 提交于 2019-12-06 11:29:35

问题


in an iPhone app, I have a UITabBar with three tabs. One has a system image, two more have custom images. These are PNGs, 30x30, palette-based, mostly transparent. These images show up fine in the simulator, but on the device, all I see is a grey gradiented square on a tab. The shapes on these images are grey to begin with, but they do show up as expected on the simulator.

Any ideas, please?


回答1:


The image should be white on transparent. It's in the UI design guide. In my case, it was grey on transparent. Simulator forgives that, the device does not.




回答2:


The device itself is pickier about image formats than the simulator is. I've had a number of instances where things showed up in the simulator and didn't on the phone. What has always worked for me is to encode all of my PNGs as 24-bit PNG-24 (in Photoshop) -- for icons and the like, the increased file size is trivial, and it solves my issues with images not showing up.




回答3:


After about 3 hours I noticed the not so obvious... the name of the file is processed with case sensitive rules on the device, but not within the XCode simulator (As of XCode 4.6).

For example:

If the actual file name (resource) is "first.png" then the following needs to be the case in your code ---

//DO THIS self.tabBarItem.image = [UIImage imageNamed:@"first.png"];

//NOT THIS self.tabBarItem.image = [UIImage imageNamed:@"First.png"];

Look into this first before changing your code.



来源:https://stackoverflow.com/questions/1934977/uitabbar-images-visible-on-simulator-disappear-on-the-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!