我在 viewWillAppear 中编写了一些代码,以更改某些按钮的背景图像。它在模拟器中运行良好。但是,当我将它加载到真实设备时,它不起作用。设备为IOS5.1.1。
有没有人知道是什么问题??谢谢!!
(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
...
//set dataTypeSelect buttons background
UIImage *tmpImage = [UIImage imageNamed:@"White.png"];
[self.dataTypeSelectBut0 setBackgroundImage:tmpImage forState:UIControlStateNormal];
[self.dataTypeSelectBut1 setBackgroundImage:tmpImage forState:UIControlStateNormal];
[self.dataTypeSelectBut2 setBackgroundImage:tmpImage forState:UIControlStateNormal];
tmpImage = [UIImage imageNamed:@"Cyan.png"];
iTDLAppDelegate *tmpAppDelegate = (iTDLAppDelegate *)[[UIApplication sharedApplication] delegate];
switch(tmpAppDelegate.viewingDataType)
{
case EnumDataType_HkHorse:
[self.dataTypeSelectBut0 setBackgroundImage:tmpImage forState:UIControlStateNormal];
break;
case EnumDataType_S1:
[self.dataTypeSelectBut1 setBackgroundImage:tmpImage forState:UIControlStateNormal];
break;
case EnumDataType_S2:
[self.dataTypeSelectBut2 setBackgroundImage:tmpImage forState:UIControlStateNormal];
break;
}
...
}