现在的位置: 首页 > 综合 > 正文

iPhone开发–模拟器上能显示图片,而设备上不能显示图片

2018年08月06日 ⁄ 综合 ⁄ 共 773字 ⁄ 字号 评论关闭

iPhone开发--模拟器上有图片,而设备上无图片这个问题之前遇到过,发现是程序中的图片和图片文件的大小写不一致造成的,后来改了大小写就好了。一直没找到官方的解释,在看Learn iPhone and iPad Cocos2D Game Development的时候,在书中的第56页找到了答案。记录下,共勉之。


警告:iOS设备上的文件名是区分大小写的!在模拟器上测试时并不区分大小写。

但是在iOS设备上实际测试时,程序就会因为大小写错误而崩溃。这个要求导致了很多让开发者头痛的问题,这也是另一个为什么要经常在设备上做实际测试的原因。为自己确立一个文件命名规则,并且坚持用下去。对我自己而言,我全部使用小写,词和词之间则用下划线分开。


WARNING:File names are case-sensitive on iOS devices! While you’re on the simulator, the filename’s
case doesn’t matter but when you switch over to testing on the device, it will most likelycrash if the file name is actually something like @“default.PNG”, as in the example.

This has caused many developers serious headaches and it’s another reason you should test onthe device often. It’s also a good idea to come up with a naming scheme for file names and stickto
it. Personally, I keep them in lowercase, using dashes where needed to separate words. 

抱歉!评论已关闭.