Class

UIAlertView

In apps that run in versions of iOS prior to iOS 8, use the UIAlertView class to display an alert message to the user. An alert view functions similar to but differs in appearance from an action sheet (an instance of UIActionSheet).

Declaration

@interface UIAlertView : UIView

Overview

UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and manage alerts in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert.

Using an Alert View

Use the properties and methods defined in this class to set the title, message, and delegate of an alert view and configure the buttons in apps that run in versions of iOS prior to iOS 8. You must set a delegate if you add custom buttons. The delegate should conform to the UIAlertViewDelegate protocol. Use the show method to display an alert view after it is configured.

Subclassing Notes

The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

Topics

Creating Alert Views

Setting Properties

delegate

The receiver’s delegate or nil if it doesn’t have a delegate.

alertViewStyle

The kind of alert displayed to the user.

title

The string that appears in the receiver’s title bar.

message

Descriptive text that provides more details than the title.

visible

A Boolean value that indicates whether the receiver is displayed.

Configuring Buttons

- addButtonWithTitle:

Adds a button to the receiver with the given title.

numberOfButtons

The number of buttons on the alert view.

- buttonTitleAtIndex:

Returns the title of the button at the given index.

- textFieldAtIndex:

Returns the text field at the given index

cancelButtonIndex

The index number of the cancel button.

firstOtherButtonIndex

The index of the first other button.

Displaying

- show

Displays the receiver using animation.

Dismissing

- dismissWithClickedButtonIndex:animated:

Dismisses the receiver, optionally with animation.

Constants

UIAlertViewStyle

The presentation style of the alert.

Relationships

Inherits From

See Also

Deprecated Classes

UIPreviewAction

A preview action, or peek quick action, that is displayed below a peek when a user swipes the peek upward.

Deprecated
UIPreviewActionGroup

A group of one or more child quick actions, each an instance of the UIPreviewAction class.

Deprecated
UIAcceleration

An instance of the UIAcceleration class, called an acceleration event, represents immediate, three-dimensional acceleration data. To receive accelerometer events, register an application object as a delegate of the shared UIAccelerometer object, as described in UIAccelerometer.

Deprecated
UIAccelerometer

The UIAccelerometer class lets you register to receive acceleration-related data from the onboard hardware. As a device moves, its hardware reports linear acceleration changes along the primary axes in three-dimensional space. You can use this data to detect both the current orientation of the device (relative to the ground) and any instantaneous changes to that orientation. You might use instantaneous changes as input to a game or to initiate some action in your application.

Deprecated
UIActionSheet

Important: UIActionSheet is deprecated in iOS 8. (Note that UIActionSheetDelegate is also deprecated.) To create and manage action sheets in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet.

Deprecated
UIDocumentMenuViewController

A list of all the available document providers for a given file type and mode, in addition to custom menu items that you add.

Deprecated
UILocalNotification

Important:UILocalNotification is deprecated in iOS 10. Use UNNotificationRequest instead. A UILocalNotification object specifies a notification that an app can schedule for presentation at a specific date and time.

Deprecated
UIMutableUserNotificationAction

Important: UIMutableUserNotificationAction is deprecated in iOS 10. Use UNNotificationAction instead. A UIMutableUserNotificationAction object represents a modifiable version of the UIUserNotificationAction class.

Deprecated
UIMutableUserNotificationCategory

Important: UIMutableUserNotificationCategory is deprecated in iOS 10. Use UNNotificationCategory instead. A UIMutableUserNotificationCategory object encapsulates information about custom actions that your app can perform in response to a local or push notification. Use instances of this class to customize the actions included in an alert when space onscreen is constrained.

Deprecated
UIPopoverController

Important: UIPopoverController is deprecated in iOS 9. In iOS 9 and later, a popover is implemented as a UIViewController presentation. To create a popover, use an instance of UIPopoverPresentationController and specify the UIModalPresentationPopover style.

Deprecated
UISearchDisplayController

Important: UISearchDisplayController is deprecated in iOS 8. (Note that UISearchDisplayDelegate is also deprecated.) To manage the presentation of a search bar and display search results in iOS 8 and later, instead use UISearchController.

Deprecated
UIStoryboardPopoverSegue

The UIStoryboardPopoverSegue class defines a specific type of segue for presenting content in a popover. For popover segues, the destination view controller contains the content to be displayed in the popover. This class provides an additional popoverController property so that your custom code has access to the popover controller object. For example, you might want to store the popover controller elsewhere in your code so that you can dismiss the popover programmatically.

Deprecated
UIUserNotificationAction

Important: UIUserNotificationAction is deprecated in iOS 10. Use UNNotificationAction instead. A UIUserNotificationAction object represents a custom action that your app can perform in response to a remote or local notification.

Deprecated
UIUserNotificationCategory

Important:UIUserNotificationCategory is deprecated in iOS 10. Use UNNotificationCategory instead. A UIUserNotificationCategory object encapsulates information about custom actions that your app can perform in response to a local or push notification.

Deprecated
UIUserNotificationSettings

Important: UIUserNotificationSettings is deprecated in iOS 10. Use UNNotificationSettings instead. A UIUserNotificationSettings object encapsulates the types of notifications that can be displayed to the user by your app.

Deprecated