Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIAlertView';s委托方法alertViewCancel:未被调用_Iphone_Objective C_Cocoa Touch_Uialertview - Fatal编程技术网

Iphone UIAlertView';s委托方法alertViewCancel:未被调用

Iphone UIAlertView';s委托方法alertViewCancel:未被调用,iphone,objective-c,cocoa-touch,uialertview,Iphone,Objective C,Cocoa Touch,Uialertview,UIAlertViewDelegate协议声明如下: // 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)alertVi

UIAlertViewDelegate
协议声明如下:

// 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
,当我现在点击模拟器中的Home按钮时,不会调用方法
alertViewCancel:
。请注意,
alertView:ClickedButtonIndex:
delegate方法在我触摸alertView上的按钮时被调用,以便正确连接代理

这是苹果那边的虫子还是我,或者是模拟器

编辑:

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

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

当系统实际取消您的警报视图时,将调用它。当你的应用程序进入后台时,你的警报视图不会再被取消,除非你的应用程序被丢弃,当你再次进入前台时,你的警报视图将再次弹出。我假设,虽然我不确定,但如果flotsam终止了您的进程,您将得到这个委托调用,作为拆卸序列的一部分


在这一点上,文档可能有点误导。“主页”按钮按取消的警报通常是这样,但现在不总是这样了。

您是否在ClickButtonIndex中执行了一些操作,以覆盖对alertViewCancel的任何调用?您能否显示创建警报视图的代码?@carbonbasednerd问得好,但是当我点击HOME按钮时,不会调用方法
alertView:ClickedButtonIndex:
。我通过收听
UIApplicationWillResignActiveNotification
通知来解决这个问题(我用这一点信息更新了我的帖子)好的,我想我明白了。这意味着在“预多任务设备”上,该方法可能会被调用,因为
UIAlertView
实际上会被取消,因此不会再次显示。但这是谁的废料
flotsam
是当系统需要更多内存时吃掉应用程序的系统进程。当设备上的内存压力很大时,flotsam会选择一个后台应用程序,并发送内存警告。如果应用程序没有释放足够的内存,
flotsam
会将其关闭。它与杀死无响应应用程序的系统进程<;代码>;>;>;>;>;>;>;>;>;>;>;看门狗>;>;>;>;>;>;>;>;>;>。这个名字是对“flotsam和jetsam”的双关语,指的是漂浮在周围的未被使用的东西。为了完整起见,我应该澄清一下,flotsam将首先发送警告,然后杀死最大的后台罪犯,而不是按时间顺序杀死应用程序,从而试图恢复内存。在iOS 5中,当你收到警告时,释放内存,并尽可能降低你的抗干扰足迹,这是一个非常好的主意。你不会再有机会了,如果你变得足够小,你很可能会被跳过去挑选更高使用率的应用程序。不被杀死在感知的“加载”时间上有很大的优势。因此我继续使用
UIApplicationWillResignActiveNotification
的方法,在应用程序处于非活动状态时关闭
UIAlertView
。@是的,这听起来是我的最佳计划