以下的UIAlertViewDelegate
协议规定:UIAlertView中的委托方法alertViewCancel:不会被调用
// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)alertViewCancel:(UIAlertView *)alertView;
不过,我有一个显示UIAlertView
,当我打到现在在模拟器主页按钮,该方法alertViewCancel:
不会被调用。请注意,当我触摸AlertView上的一个按钮时,alertView:clickedButtonAtIndex:
委托方法会被调用,以便代理正确连接。
这是苹果方面的缺陷,还是我,或者是模拟器?
编辑:
我目前通过听取UIApplicationWillResignActiveNotification
通知,我做以下驳回AlertView解决此问题:
[self.currentAlert dismissWithClickedButtonIndex:-1 animated:NO];
[self.currentAlert release];
self.currentAlert = nil;
你正在做点clickButtonAtIndex会覆盖alertViewCancel的任何调用吗? – carbonbasednerd 2012-01-17 13:43:08
您可以显示创建警报视图的代码吗? – rishi 2012-01-17 13:43:40
@carbonbasednerd好问题,但是当我点击HOME按钮时,alertView:clickedButtonAtIndex:方法不会被调用。我通过听'UIApplicationWillResignActiveNotification'通知来解决这个问题(我用这一点信息更新了我的帖子) – Besi 2012-01-17 13:47:43