gpt4 book ai didi

iphone - UIAlertView的委托(delegate)方法alertViewCancel : does not get called

转载 作者:行者123 更新时间:2023-12-03 20:52:52 25 4
gpt4 key购买 nike

UIAlertViewDelegate 协议(protocol)声明如下:

// 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: 委托(delegate)方法,以便正确连接委托(delegate)。

这是苹果方面的错误还是我的错误,或者可能是模拟器的错误?

编辑:

我目前通过监听 UIApplicationWillResignActiveNotification 通知来解决此问题,在该通知中我执行以下操作来关闭 AlertView:

[self.currentAlert dismissWithClickedButtonIndex:-1 animated:NO];
[self.currentAlert release];
self.currentAlert = nil;

最佳答案

当系统实际取消您的警报 View 时调用它。当您的应用程序进入后台时,您的警报 View 将不再被取消,除非您的应用程序被漂浮物进程驱逐,否则当您再次成为前台时,您的警报 View 将再次弹出。尽管我不确定,但我认为如果 flotsam 终止了您的进程,您将在拆卸序列中得到此委托(delegate)调用。

文档在这一点上可能有点误导。过去的情况是按主页按钮会取消警报,但现在情况不再总是如此。

关于iphone - UIAlertView的委托(delegate)方法alertViewCancel : does not get called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8895522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com