UIAlertViewDelegate
The interface for the delegate of an alert view object.
Declaration
@MainActor protocol UIAlertViewDelegate : NSObjectProtocolOverview
The delegate implements the button actions and any other custom behavior. Some of the methods defined in this protocol are optional.
If you add your own buttons or customize the behavior of an alert view, implement a delegate conforming to this protocol to handle the corresponding delegate messages. Use the delegate property of an alert view to specify one of your application objects as the delegate.
If you add your own buttons to an alert view, the delegate must implement the alertView(_:clickedButtonAt:) message to respond when those buttons are clicked; otherwise, your custom buttons do nothing. The alert view is automatically dismissed after the alertView(_:clickedButtonAt:) delegate method is invoked.
Optionally, you can implement the alertViewCancel(_:) method to take the appropriate action when the system cancels your alert view. If the delegate doesn’t implement this method, the default behavior is to simulate the user clicking the cancel button and closing the view.
You can also optionally augment the behavior of presenting and dismissing alert views using the methods in Customizing behavior.
Topics
Responding to actions
Customizing behavior
alertViewShouldEnableFirstOtherButton(_:)willPresent(_:)didPresent(_:)alertView(_:willDismissWithButtonIndex:)alertView(_:didDismissWithButtonIndex:)