Launch the Action Sheet in iOS

Updated 27 March 2024

Save

An action sheet can be useful in displaying the options to the users. Launch the Action sheet in iOS using the UIKit’s UIAlertViewController class.

In this blog, we will explore how you can display the options to the users using the UIAlertViewController’s property Style.

Launch action sheet in iOS

If you want to perform multiple actions from one single button you can make an action sheet that will come up from the bottom of the screen.

You can dismiss the action sheet using the cancel action.

You have to set the style of cancel as “.cancel” and others have a “.normal” style.

The action sheet comes from the bottom of the iPhone. To launch on iPad you have to set the frame of that action sheet. A simple example using an action sheet in Swift is. shown below.

Methods of those actions:-

Sometimes, there are multiple options to display to the users. We can achieve this by adding a for loop to the available options array.

The below code describes how you can achieve this.

addActions is a method defined in the extension for the UIAlertViewController.

Here is the output of the above code.

Launch the Action Sheet in iOS

Conclusion

The action sheet is a popular and efficient way to display options to the users.

It can handle multiple options from an array.

We hope you would like this blog.

Please check our other blogsĀ here.

You may also check our Flutter app development page.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home