預期的行爲是在單擊播放動作時更改圖像(從播放到暫停,從暫停到播放)。這可以在4.x版本中按預期工作。在版本3.2中,setImage不起作用,意味着setImage不設置圖像。調用imageForState:UIControlStateNormal在3.2版本中返回null。有任何想法嗎?setImage:forState:在iOS 3.2中不起作用
@interface TestViewController : UIViewController {
IBOutlet UIButton *playButton;
BOOL play;
}
- (IBAction) play:(id)sender;
@end
@implementation TestViewController
- (IBAction) play:(id)sender {
if (play == YES) {
[playButton setImage:[UIImage imageNamed:@"pause"] forState:UIControlStateNormal];
play = NO;
} else {
[playButton setImage:[UIImage imageNamed:@"play"] forState:UIControlStateNormal];
play = YES;
}
//[playButton imageForState:UIControlStateNormal]
}
@end
如果您包含擴展名,例如'@「play.png」',會發生什麼? – 2011-04-01 19:05:59