Images in the iPhone app are displayed in Simulator, but not when compiling to the device

I study iPhone development and created a simple application with an image that changes to another image when you click on it.

If I build it on a simulator, it works fine, but if I build it on a device, images will not appear. I feel that they are not being copied. I checked that they were correctly named, and I made sure that I imported them into "resources"

I don’t think this is a problem with the code, because I added a thing so that the text also appears when the image is playing, and this works, so the button is still doing something there, it just doesn’t have an image on it.

-(IBAction)changeImage:(id)sender { [fortuneCookieButton setImage:[UIImage imageNamed:@"Image2.jpg"] forState:UIControlStateNormal]; label.hidden = NO; } -(IBAction)restoreImage:(id)sender { [fortuneCookieButton setImage:[UIImage imageNamed:@"Image1.jpg"] forState:UIControlStateNormal]; label.hidden = YES; } 
+4
source share
8 answers

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

+8
source

just to share with you, I had the same problem and I found a solution: I used lowercase in the file name and in the upper case of the code. The Simulator case was not a problem because the Mac file system is not case sensitive, but it does not work on the iPad because the iOS file system is case sensitive .; -)

+5
source

I had this problem. Unusually, the image worked in the past, and then just stopped appearing on the device one day.

It was a PNG.

I opened it in GIMP and saved it again. Then he returned to work. I do not know why.

Are crazy.

+3
source

This applies only to PNG images, as well as for JPG and other formats, you have the same problem. If this is only for PNG images, they may not be compressed. Try the following.

Choose the goal of your project and go to its information. Go to the build tab. In the configuration, select "All configurations" from the "Configuration" section. Now write "COMPRESS_PNG_FILES" in the search bar and look at the status of the flag. If it is not installed, then make it checked and it will work. But if it has already been verified, then there must be another reason in your project.

In a later case, I will ask you to create a new dummy project and check by adding 2-3 images, regardless of whether it comes or not.

0
source

Clear caches delete previous build and try again.

0
source

I also had the same problem and it was caused by another reason: in my project there are image files with the same name! Since my application has many images, I inadvertently included images with the same name. The simulator is more tolerant and shows images very well; however, when building on the device, none of the images with the same name were copied to the assembly directory. Obviously, xcode is more legible for the device: since all the 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, because it does not know which one to choose.

0
source

I have the same problem. In my case, the problems are related to the UILabel over the UIImageView, which 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 to Plain, it works now. I am using Xcode 6.2.

0
source

on top of all suggestions - this did not work for me until I restarted the device

0
source

All Articles