UIImage imageNamed returning wrong image

730 views Asked by At

I'm having a weird problem using [UIImage imageNamed:] method to set table view cells' backgrounds.

I typically do this for a cell:

backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_background.png"]];

For some unknown reason, the image returned is not "cell_background.png". It actually returns an older version of the image which has a different name now ("button_background.png"). The image preview for cell_background in XCode shows the right image, and "open" or "reveal in finder" also are ok. I tried to remove all images from the project and put them back, but the problem remains.

What could cause imageNamed: to load an older version of the image or an image with another name?

1

There are 1 answers

1
Reza Sadr On BEST ANSWER

Clean up all targets. Rebuild the project. Make sure the image name is correct. Check for upper-case lower-case as well, in iPhone Hello.png != hello.png