Images in iPhone app appear in Simulator, but not when compiled to device

回眸只為那壹抹淺笑 提交于 2019-12-05 16:50:00

Does the case (upper/lower) of all your file names match exactly for all letters? Source code & project & Mac?

just to share with you, I had this same problem and I found out the solution: I was using lower case in the file name and upper case in code. The thing is on Simulator there was no problem because Mac file system is case-insensitive but in the iPad it didn't work because iOS file system is case sensitive. ;-)

I had this problem. Bizarrely the image had been working in the past, then just stopped appearing on the device one day.

It was a PNG.

I opened it in GIMP and saved it again. Then it went back to working again. No idea why.

Crazy.

Is it the case with only PNG images or also for JPG & other format you're having same issue. If it's only for PNG image, then it might be possible they're not being compressed. Try the following way.

Select your project target & go into its info. Here go into the build tab. In the configuration select "All Configurations" from Configuration section. Now, write "COMPRESS_PNG_FILES' in the search bar. And see the status of the check-box. IF it's unchecked, then make it checked & it will work. But if it's already checked, then there should be other reason in your project.

In the later case, I would request you to create a new dummy project & check by adding 2-3 images whether it's coming or not.

Clear caches delete the previous build and try again.

I also had same problem, and it was caused by a different reason: my project has image files with the same name! Since my app has many images, I inadvertently included images with the same name. Simulator is more tolerant and show the images just fine; however, when built on device, neither of the images of the same name were copied to the build directory. Obviously xcode is more picky for device: since all images go to the same directory, the file names must be different. When there are files with the same name, xcode refuses to copy any of them since it doesn't know which one to pick.

I have the same problem. In my case, the issues is to do with the UILabel above the UIImageView that shows the image. When I change the type of UILabel to AttributedText (In Property Inspector), my real devices cannot load the image. When I change it back to Plain, it works now. I use XCode 6.2.

on top of all suggestions - it wasn't work for me until I restarted the device

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