Josh Sherick
Josh Sherick

Reputation: 2161

Button images not working on device

so, I made my app and everything, and it has a few UI buttons with background images, which worked fine when it was on the computer and i was testing in iphone sim. now, when i test on a real iphone, the buttons just show up as standard UICustomWhiteRect or whatever it is called. here is the code i use to make them:

filepath = [[NSBundle mainBundle]
            pathForResource:@"button-half@2x" 
            ofType:@"png"];
[sendAsOneSMSButton setBackgroundImage:[UIImage imageWithContentsOfFile:filepath] forState:UIControlStateNormal];

i also have one for when it is pressed, which i set just like that. and just so no one asks me, the images for the buttons are both in my main folder the same folder my .xcodeproj file is in. what could i be doing wrong?

SO: they work in iPhone Simulator, they show up as normal buttons without images on a real iPhone.

Upvotes: 0

Views: 250

Answers (2)

Anomie
Anomie

Reputation: 94844

The first thing to check in a case like this is whether your images are really named "[email protected]", or if they are in fact "[email protected]", "[email protected]", or the like. The usual filesystem on OS X (and therefore on the simulator) is case-insensitive, while the filesystem on the device is case-sensitive.

Upvotes: 1

W Dyson
W Dyson

Reputation: 4634

Make sure the image file is included in the Bundle Resources folder.

Upvotes: 0

Related Questions