See Also: UIAlertViewDelegate Members
System.Object
MonoTouch.Foundation.NSObject
MonoTouch.UIKit.UIAlertViewDelegate
RemarksOverview
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 UIAlertView.WeakDelegate 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 UIAlertViewDelegate.Clicked(UIAlertView, int) message to respond when those buttons are clicked; otherwise, your custom buttons do nothing. The alert view is automatically dismissed after the UIAlertViewDelegate.Clicked(UIAlertView, int) delegate method is invoked.
Optionally, you can implement the UIAlertViewDelegate.Canceled(UIAlertView) 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.”
Tasks
Responding to Actions
Customizing Behavior
- UIAlertViewDelegate.WillPresent(UIAlertView)
- UIAlertViewDelegate.Presented(UIAlertView)
- UIAlertViewDelegate.WillDismiss(UIAlertView, int)
- UIAlertViewDelegate.Dismissed(UIAlertView, int)
Canceling
Instance Methods
alertView:clickedButtonAtIndex:
Sent to the delegate when the user clicks a button on an alert view.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
Parameters
- alertView
The alert view containing the button.
- buttonIndex
The position of the clicked button. The button indices start at 0.
Discussion
The receiver is automatically dismissed after this method is invoked.
Availability
- Available in iPhone OS 2.0 and later.
Declared In
UIAlertView.halertView:didDismissWithButtonIndex:
Sent to the delegate after an alert view is dismissed from the screen.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
Parameters
- alertView
The alert view that was dismissed.
- buttonIndex
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.
Discussion
This method is invoked after the animation ends and the view is hidden.
Availability
- Available in iPhone OS 2.0 and later.
See Also
Declared In
UIAlertView.halertView:willDismissWithButtonIndex:
Sent to the delegate before an alert view is dismissed.
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
Parameters
- alertView
The alert view that is about to be dismissed.
- buttonIndex
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.
Discussion
This method is invoked before the animation begins and the view is hidden.
Availability
- Available in iPhone OS 2.0 and later.
See Also
Declared In
UIAlertView.halertViewCancel:
Sent to the delegate before an alert view is canceled.
- (void)alertViewCancel:(UIAlertView *)alertView
Parameters
- alertView
The alert view that will be canceled.
Discussion
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 UIAlertViewDelegate.WillDismiss(UIAlertView, int) and UIAlertViewDelegate.Dismissed(UIAlertView, int) methods are invoked after this method.
Availability
- Available in iPhone OS 2.0 and later.
Declared In
UIAlertView.hdidPresentAlertView:
Sent to the delegate after an alert view is presented to the user.
- (void)didPresentAlertView:(UIAlertView *)alertView
Parameters
- alertView
The alert view that was displayed.
Availability
- Available in iPhone OS 2.0 and later.
See Also
Declared In
UIAlertView.hwillPresentAlertView:
Sent to the delegate before a model view is presented to the user.
- (void)willPresentAlertView:(UIAlertView *)alertView
Parameters
- alertView
The alert view that is about to be displayed.
Availability
- Available in iPhone OS 2.0 and later.
See Also
Declared In
UIAlertView.h
RequirementsNamespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0