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.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

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