0
當我點擊同一個酒吧按鈕項時,我嘗試執行不同的代碼。每當我點擊背景圖片變化。我檢查這是哪一個,然後選擇要執行的代碼。這有效,但當應用程序來自後臺的按鈕不工作。一些想法?當應用程序來自背景時,酒吧按鈕項不起作用
這是代碼viewDidLoad中:
[self.btnOnOff setImage:[UIImage imageNamed:@"iconON.png"]];
self.btnOnOff.tintColor = [UIColor greenColor];
這是當用戶點擊
-(IBAction)btnOnOffAction:(id)sender
{
UIImage* selectedImgOFF = [UIImage imageNamed:@"iconOFF.png"];
UIImage* selectedImgON = [UIImage imageNamed:@"iconON.png"];
// UNAVAILABLE
if ([self.btnOnOff.image isEqual:selectedImgON])
{
// Ask user confirmation
self.alertConfirmationStatus = [[UIAlertView alloc] initWithTitle:@"Status of app" message:@"Do you want to switch to UNAVAILABLE ?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[self.alertConfirmationStatus show];
}
// AVAILABLE
else if ([self.btnOnOff.image isEqual:selectedImgOFF])
{
// Ask user confirmation
self.alertConfirmationStatus = [[UIAlertView alloc] initWithTitle:@"Status of app" message:@"Do you want to switch to \n AVAILABLE ?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[self.alertConfirmationStatus show];
}
else {}
}
預先感謝您
謝謝你的回答。 – dev1001 2014-10-03 13:50:24