An object that displays an alert message to the user.
- iOS 8.0+
- tvOS 9.0+
Use this class instead of
UIAlert to display alerts. After configuring the alert controller with the actions and style you want, present it using the
In addition to displaying a message to a user, you can associate actions with your alert controller to give the user a way to respond. For each action you add using the
add method, the alert controller configures a button with the action details. When the user taps that action, the alert controller executes the block you provided when creating the action object. Listing 1 shows how to configure an alert with a single action.
When configuring an alert with the
alert style, you can also add text fields to the alert interface. The alert controller lets you provide a block for configuring your text fields prior to display. The alert controller maintains a reference to each text field so that you can access its value later.
UIAlert 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.