How to create a UIActionSheet and respond to it

This will bring up the UIActionSheet on iPhone devices from the bottom of the screen:

You can add more buttons if you like by comma separating them. If you don’t feel the need for a button (for example the destructive button) simply set it to nil and it won’t be displayed.

In order to respond to it your class must conform to the UIActionSheetDelegate protocol. Here’s how you implement the method and query which button has been pressed:

The buttonIndex counts the buttons from top to bottom of how they are displayed, starting with 0.

One thought on “How to create a UIActionSheet and respond to it

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.