Search code examples
iosuialertviewnsnotificationcenternsnotificationsuialertviewdelegate

Notification or delegate called when UIAlertView is hidden/removed


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?


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