Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

milktooth

macrumors member
Original poster
Oct 30, 2009
32
0
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.

Code:
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?
 
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?
 
They're coming back as nil.

Not sure why this could be. They're in the project folder and listed in resources.
 
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.
 
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.
 
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"
 
Are you copying the files into your destination group's folder?
 

Attachments

  • Screen shot 2009-11-05 at 12.39.26 PM.png
    Screen shot 2009-11-05 at 12.39.26 PM.png
    51.2 KB · Views: 88
I've found the cause. I hope it's not a sign of bigger problems.

Seems like the files got corrupted somehow.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.