Conforms to | |
Framework | /System/Library/Framework/UIKit.framework |
Availability | Available in iOS 2.0 and later. |
Declared in | UIAlertView.h |
The UIAlertViewDelegate
protocol defines the methods a delegate of a UIAlertView
object should implement. 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:clickedButtonAtIndex:
message to respond when those buttons are clicked; otherwise, your custom buttons do nothing. The alert view is automatically dismissed after the alertView:clickedButtonAtIndex:
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 does not 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.”
– willPresentAlertView:
– didPresentAlertView:
– alertView:willDismissWithButtonIndex:
– alertView:didDismissWithButtonIndex:
Sent to the delegate when the user clicks a button on an alert view.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
The alert view containing the button.
The position of the clicked button. The button indices start at 0
.
The receiver is automatically dismissed after this method is invoked.
UIAlertView.h
Sent to the delegate after an alert view is dismissed from the screen.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
The alert view that was dismissed.
The index of the button that was clicked. The button indices start at 0
. If this is the cancel button index, the alert view is canceling. If -1
, the cancel button index is not set.
This method is invoked after the animation ends and the view is hidden.
UIAlertView.h
Sent to the delegate before an alert view is dismissed.
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
The alert view that is about to be dismissed.
The index of the button that was clicked. The button indices start at 0
. If this is the cancel button index, the alert view is canceling. If -1
, the cancel button index is not set.
This method is invoked before the animation begins and the view is hidden.
UIAlertView.h
Sent to the delegate before an alert view is canceled.
- (void)alertViewCancel:(UIAlertView *)alertView
The alert view that will be canceled.
If the alert view’s delegate does not implement this method, clicking the cancel button is simulated and the alert view is dismissed. Implement this method if you need to perform some actions before an alert view is canceled. An alert view can be canceled at any time by the system—for example, when the user taps the Home button. The alertView:willDismissWithButtonIndex:
and alertView:didDismissWithButtonIndex:
methods are invoked after this method.
UIAlertView.h
Sent to the delegate after an alert view is presented to the user.
- (void)didPresentAlertView:(UIAlertView *)alertView
The alert view that was displayed.
UIAlertView.h
Sent to the delegate before a model view is presented to the user.
- (void)willPresentAlertView:(UIAlertView *)alertView
The alert view that is about to be displayed.
UIAlertView.h
Last updated: 2008-05-16