0

我正在尝试查找隐藏或显示警报视图时调用的委托/协议甚至通知。这些事件是否会触发我可以监听的通知或回调?

我知道 UIAlertView 协议,但这不是我想要的,我正在寻找实际的显示和隐藏事件以在完成后执行操作。

这存在吗?

4

2 回答 2

1

如果你想了解你自己展示的 AlertViews,你正在寻找UIAlertViewDelegate协议

didPresentAlertView:alertView:didDismissWithButtonIndex:

如果您想知道操作系统何时显示 AlertView,您可以尝试UIWindowDidBecomeVisibleNotificationUIWindowDidBecomeHiddenNotificationUIWindow类引用中,然后检查windowLevel属性是否等于UIWindowLevelAlert

于 2014-04-05T20:36:01.393 回答
0

一个简单的检查方法NSNotifications是将该代码添加到您的AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notification:) name    :nil object:nil];

    return YES;
}

-(void)notification:(NSNotification*)notification
{
    NSLog(@"Notification name is %@, \n sent by %@\n\n",[notification name], [[notification object] description] );
}

我测试了这个代码触发UIAlertViews,我从来没有收到NSNotification相关的。
所以可能没有NSNotification相关的UIAlertViews

于 2014-04-10T12:28:05.120 回答