Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use a UIAlertView vs. UIActionSheet

Tags:

Are there situations where a UIAlertView is better to use than a UIActionSheet? What are the typical scenarios where you would use one over the other?

I'm programming a navigation bar button to open a UIWebView in an external application, and at first I started programming a UIAlertView, then I thought that an action sheet might be better for this situation.

Are there any formal guidelines for which to use in different situations? Thanks.

like image 693
nevan king Avatar asked Jul 28 '09 11:07

nevan king


People also ask

What is a UIAlertController?

An object that displays an alert message.

Which method will present the action sheet?

You can present an action sheet from a toolbar, tab bar, button bar item, or from a view. This class takes the starting view and current platform into account when determining how to present the action sheet.

What is action sheet?

An action sheet is a modal view that presents choices related to an action people initiate. DEVELOPER NOTE When you use SwiftUI, you can enable action sheet functionality in all platforms by specifying a presentation modifier for a confirmation dialog.

How do you display an action sheet?

You show an action sheet by using the actionSheet(isPresented:content:) view modifier to create an action sheet, which then appears whenever the bound isPresented value is true . The content closure you provide to this modifier produces a customized instance of the ActionSheet type.


2 Answers

From Apple's iPhone Human Interface Guidelines:

Alerts, action sheets, and modal views are designed to communicate different things:

  • Alerts give users important information that affects their use of the application (or the device). Alerts are usually unexpected, because they generally tell users about a problem or a change in the current situation that might require users to take action.
  • Action sheets give users additional choices related to the action they are currently taking. Users learn to expect the appearance of an action sheet when they tap a toolbar button that begins either a potentially destructive action (such as deleting all recent calls) or an action that can be completed in different ways (such as a send action for which users can specify one of several destinations).
  • Modal views provide more extensive functionality in the context of the current task or provide a way to perform a subtask directly related to the user’s workflow.
like image 159
Brad Larson Avatar answered Sep 18 '22 00:09

Brad Larson


Improving the @Brad Larson♦ answer and updating the informations (because the link in his answer is broken), here more details when you should be use an alert, an action sheet or a modal view:

Alert:

  • Displays a required title and an optional message
  • Contains one or more buttons

The infrequency with which alerts appear helps users take them seriously. It’s best to minimize the number of alerts your app displays, and make sure each one offers critical information and useful choices.

Action Sheet:

  • Appears as the result of a user action
  • Displays two or more buttons

Use an action sheet to:

  • Provide alternative ways to complete a task. An action sheet lets you to provide a range of choices that make sense in the context of the current task, without giving these choices a permanent place in the UI.
  • Get confirmation before completing a potentially dangerous task. An action sheet prompts users to think about the potentially dangerous effects of the step they’re about to take and gives them some alternatives.

Modal View:

  • Can occupy the entire screen, the entire area of a parent view (such as a popover), or a portion of the screen
  • Contains the text and controls that are necessary to complete the task
  • Usually displays a button that completes the task and dismisses the view and a Cancel button that abandons the task and dismisses the view

Use a modal view when you need to offer the ability to accomplish a self-contained task related to your app’s primary function. A modal view is especially appropriate for a multistep subtask that requires UI elements that don’t belong in the main app UI all the time.

Source: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Alerts.html

like image 35
Filipe Brito Avatar answered Sep 19 '22 00:09

Filipe Brito