quantumpotato
quantumpotato

Reputation: 9767

Loading an image from a .png returns nil on device, fine in Simulator

Some of them are working, but not all. For example, on one screen I am loading 6 images from a file and displaying each of them inside a button. The first 4 are appearing but not the latter ones.

On my simulator (iPhone & iPad), all 6 display correctly.

A new view controller after that expects an array of images, but logging the array shows an empty array, whereas the simulator logs:

  self.images: (
"<UIImage: 0x5357270>",
"<UIImage: 0x5316d10>",
"<UIImage: 0x530dcd0>",
"<UIImage: 0x5345160>",
"<UIImage: 0x5345340>",
"<UIImage: 0x530dcd0>"

The file names are lower cased as are the strings to access them. (referenced from Image loads in simulator but not device? )

Any idea why this is happening?

Upvotes: 1

Views: 190

Answers (3)

quantumpotato
quantumpotato

Reputation: 9767

Turned off png compression, also reopened the images in photoshop and saved - discarding Fireworks data.

Upvotes: 0

Jordan Brown
Jordan Brown

Reputation: 638

Make sure the images are copied into the project, not just referenced.

To do this, make a folder with all the images. Delete all the images in the app. Add Existing Files-> find the folder with all the images -> make sure the "copy into project" checkbox is checked.

Upvotes: 1

Mahadevan Sreenivasan
Mahadevan Sreenivasan

Reputation: 1132

On the iOS, the filenames should not have spaces I believe. Try removing spaces / or replacing them with underscores in your images.

Upvotes: 0

Related Questions