我正在尝试查找隐藏或显示警报视图时调用的委托/协议甚至通知。这些事件是否会触发我可以监听的通知或回调?
我知道 UIAlertView 协议,但这不是我想要的,我正在寻找实际的显示和隐藏事件以在完成后执行操作。
这存在吗?
我正在尝试查找隐藏或显示警报视图时调用的委托/协议甚至通知。这些事件是否会触发我可以监听的通知或回调?
我知道 UIAlertView 协议,但这不是我想要的,我正在寻找实际的显示和隐藏事件以在完成后执行操作。
这存在吗?
如果你想了解你自己展示的 AlertViews,你正在寻找UIAlertViewDelegate协议
didPresentAlertView:
和alertView:didDismissWithButtonIndex:
如果您想知道操作系统何时显示 AlertView,您可以尝试UIWindowDidBecomeVisibleNotification
在UIWindowDidBecomeHiddenNotification
UIWindow类引用中,然后检查windowLevel
属性是否等于UIWindowLevelAlert
一个简单的检查方法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
。