Conforms to | |
Framework | /System/Library/Framework/UIKit.framework |
Availability | Available in iOS 2.0 and later. |
Declared in | UIActionSheet.h |
The UIActionSheetDelegate
protocol defines the methods a delegate of a UIActionSheet
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 action sheet, implement a delegate conforming to this protocol to handle the corresponding delegate messages. Use the delegate
property of the action sheet object to specify one of your application objects as the delegate.
If you add your own buttons to an action sheet, the delegate must implement the actionSheet:clickedButtonAtIndex:
message to respond when those buttons are clicked; otherwise, your custom buttons do nothing. The action sheet is automatically dismissed after the actionSheet:clickedButtonAtIndex:
delegate method is invoked.
Optionally, you can implement the actionSheetCancel:
method to take the appropriate action when the system cancels your action sheet. 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 action sheets using the methods in “Customizing Behavior.”
– willPresentActionSheet:
– didPresentActionSheet:
– actionSheet:willDismissWithButtonIndex:
– actionSheet:didDismissWithButtonIndex:
Sent to the delegate when the user clicks a button on an action sheet.
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
The action sheet 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.
UIActionSheet.h
Sent to the delegate after an action sheet is dismissed from the screen.
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
The action sheet 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 action sheet is canceling. If -1
, the cancel button index is not set.
This method is invoked after the animation ends and the view is hidden.
UIActionSheet.h
Sent to the delegate before an action sheet is dismissed.
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex
The action sheet that is about to be dismissed.
The index of the button that was clicked. If this is the cancel button index, the action sheet is canceling. If -1
, the cancel button index is not set.
This method is invoked before the animation begins and the view is hidden.
UIActionSheet.h
Sent to the delegate before an action sheet is canceled.
- (void)actionSheetCancel:(UIActionSheet *)actionSheet
The action sheet that will be canceled.
If the action sheet’s delegate does not implement this method, clicking the cancel button is simulated and the action sheet is dismissed. Implement this method if you need to perform some actions before an action sheet is canceled. An action sheet can be canceled at any time by the system—for example, when the user taps the Home button. The actionSheet:willDismissWithButtonIndex:
and actionSheet:didDismissWithButtonIndex:
methods are invoked after this method.
UIActionSheet.h
Sent to the delegate after an action sheet is presented to the user.
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet
The action sheet that was displayed.
UIActionSheet.h
Sent to the delegate before an action sheet is presented to the user.
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
The action sheet that is about to be displayed.
UIActionSheet.h
Last updated: 2008-05-29