iOS Reference Library Apple Developer
Search

UIActionSheetDelegate Protocol Reference

Conforms to
Framework
/System/Library/Framework/UIKit.framework
Availability
Available in iOS 2.0 and later.
Declared in
UIActionSheet.h
Related sample code

Overview

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.”

Tasks

Responding to Actions

Customizing Behavior

Canceling

Instance Methods

actionSheet:clickedButtonAtIndex:

Sent to the delegate when the user clicks a button on an action sheet.

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

Parameters
actionSheet

The action sheet 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 iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheet:didDismissWithButtonIndex:

Sent to the delegate after an action sheet is dismissed from the screen.

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex

Parameters
actionSheet

The action sheet 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 action sheet 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 iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheet:willDismissWithButtonIndex:

Sent to the delegate before an action sheet is dismissed.

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex

Parameters
actionSheet

The action sheet that is about to be dismissed.

buttonIndex

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.

Discussion

This method is invoked before the animation begins and the view is hidden.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

actionSheetCancel:

Sent to the delegate before an action sheet is canceled.

- (void)actionSheetCancel:(UIActionSheet *)actionSheet

Parameters
actionSheet

The action sheet that will be canceled.

Discussion

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.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

didPresentActionSheet:

Sent to the delegate after an action sheet is presented to the user.

- (void)didPresentActionSheet:(UIActionSheet *)actionSheet

Parameters
actionSheet

The action sheet that was displayed.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h

willPresentActionSheet:

Sent to the delegate before an action sheet is presented to the user.

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet

Parameters
actionSheet

The action sheet that is about to be displayed.

Availability
  • Available in iOS 2.0 and later.
Declared In
UIActionSheet.h



Last updated: 2008-05-29

Did this document help you? Yes It's good, but... Not helpful...