4
votes

I am creating UIImageView(s) and adding these views to a UIScrollView. The images show up when I am testing on a simulator, but when I test on an iphone 5s the images don't show up. Below is a list of things I have tried:

  1. Clean Build

  2. Reinstall App

  3. Then I thought maybe it was a problem with retina images so I added retina images (the images are white pngs): enter image description here

    • I am using the images as such:

      UIButton *doneBttn = [UIButton buttonWithType:UIButtonTypeCustom]; [doneBttn setImage:[UIImage imageNamed:@"addButton.png"] forState:UIControlStateNormal]; [doneBttn setImage:[UIImage imageNamed:@"addButtonSelected.png"] forState:UIControlStateHighlighted]; [doneBttn setFrame:CGRectMake(0, 0, 50 , 30)]; [doneBttn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside]; [uiNavView addMenuBarButtonRight:doneBttn];

    • I know the code above works, because the image is displayed in the simulator.

What do I need to change to get the image to display on my device? Also, I have checked to make sure the files are in the xcode project directory, and not just linked.

1

1 Answers

4
votes

I also faced this issue once, the cause of this issue was that I am not taking care of image name by assigning it to UIImageView, make sure that you are assigning UIImageView the exact name of the image as it is in the main bundle.

The simulator can read the image name if there is any case-sensitive issue or some extension issue like i.e. .png , .jpg, but device never reads the image name if there are issues in the naming conventions, device always treat the image name as exact.