Question

I am trying to find what delegate/protocol or even notification is called when an alert view is hidden or shown. Do these events trigger a notification or callback that I can listen for?

I know the UIAlertView protocol, but that's not what I am looking for, I am looking for the actual display and hide events to perform actions after they are completed.

Does this exist?

Was it helpful?

Solution

If you want to know about AlertViews you've presented yourself, you're looking for UIAlertViewDelegate protocol

didPresentAlertView: and alertView:didDismissWithButtonIndex:

If you want to know when an AlertView has been shown by the OS, you can try UIWindowDidBecomeVisibleNotification and UIWindowDidBecomeHiddenNotification in the UIWindow class reference, then check if the windowLevel property is equal to UIWindowLevelAlert

OTHER TIPS

An easy way to check NSNotifications is adding that code to your 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] );
}

I tested this code triggering UIAlertViews and I never receive an NSNotification related to.
So probably there aren't NSNotificationrelated to UIAlertViews.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top