Here’s one that will trip you up if you aren’t careful…look at this code:
timerButton = [[UIButton alloc] initWithFrame:CGRectMake(104, 410, 50, 50)]; // Notice the filename "timer.png" [timerButton setBackgroundImage:[UIImage imageNamed:@"timer.png"] forState:UIControlStateNormal]; [timerButton addTarget:self action:@selector(buttonPressed:) forControlEvents: UIControlEventTouchUpInside]; [self.view addSubview:timerButton];
Simple enough, create a button, use the image timer.png for the normal state, and all is well…if you run this code in the simulator. Problem is, if the actual filename of the image is Timer.png the png file will not appear when running this code on device.
If you haven’t run into this while developing an iPhone app, you can’t fully appreciate how time consuming it can be to track this down.
Note: I ran into this while working with Xcode 3.2.1 and building for iPhone OS 3.1.2