View Full Version : Button images not loading.

Nov 5, 2009, 10:42 AM
I've cleaned and cleaned and cleaned. I've checked to see if the files are there. They're listed in the resources. Not a whisper of a complain from XCode. But, try as I might, the button images won't load. Just blank buttons.

UIImage *buttonImagePressedFour = [UIImage imageNamed:@"greenbuttondown.png"];
UIImage *stretchableButtonImagePressedFour = [buttonImagePressedFour stretchableImageWithLeftCapWidth:22 topCapHeight:0];

UIImage *buttonImagePressedFive = [UIImage imageNamed:@"redbuttondown.png"];
UIImage *stretchableButtonImagePressedFive = [buttonImagePressedFive stretchableImageWithLeftCapWidth:22 topCapHeight:0];

[timerButton setBackgroundImage:stretchableButtonImagePressedFour forState:UIControlStateHighlighted];
[timerStopButton setBackgroundImage:stretchableButtonImagePressedFive forState:UIControlStateHighlighted]

What gives?

Nov 5, 2009, 10:49 AM
Check if the UIImages being returned by imageNamed: are nil. If they are then there is something wrong with the file names/you are not actually copying them into the bundle. If this is not the case then they are loading and the error must be elsewhere. I note you are setting these images for state UIControlStateHighlighted only. Are the buttons actually in this state?

Nov 5, 2009, 10:58 AM
They're coming back as nil.

Not sure why this could be. They're in the project folder and listed in resources.

Nov 5, 2009, 10:59 AM
They're coming back as nil.

Not sure why this could be. They're in the project folder and listed in resources.

With those exact names. Remembering "a.png" is not the same as "a.PNG" or "A.png"...

Nov 5, 2009, 12:46 PM
The file names check out fine -- all lower case.

I haven't changed any code nor changed the file names. However, I did replace the files with updated versions. I guess the cause lies there.

Nov 5, 2009, 01:12 PM
Delete the build folder and rebuild.

It's often a difference in the case.

Does this work on the Sim?

Look inside the application bundle in the build folder, not just in the project Resources folder.

Nov 5, 2009, 01:26 PM
Tried that. Still doesn't work. Now I'm also getting the message:

Could not load the "back.png" image referenced from a nib in the bundle with
identifier "com.yourcompany.Koala-Hat"

Nov 5, 2009, 01:40 PM
Are you copying the files into your destination group's folder?

Nov 5, 2009, 02:08 PM
Yep. I've even double checked to see if they're there.

Nov 5, 2009, 02:26 PM
I've found the cause. I hope it's not a sign of bigger problems.

Seems like the files got corrupted somehow.