Presents an alert or action sheet over the current interface controller.
- watchOS 2.0+
The title of the alert. Use this string to convey the intent of your alert.
The text to display for the body of the alert. Use this string to display secondary information related to the alert.
The preferred style of the sheet. Use the available constants to specify the type of sheet (alert or action) to display and the configuration of the buttons.
An array of
WKAlertobjects that describe the custom buttons to display. The array must contain at least one button. For the
WKAlertstyle, the array must contain exactly two buttons. The block associated with each button should dismiss the sheet in addition to performing any other tasks.
Controller Style .side By Side Buttons Alert
Use action and alert sheets to interrupt the current workflow temporarily and display a message to the user. The sheet itself places a blurred layer over your interface controller and displays the title and message text on top of that. If you provided action buttons, those buttons are displayed at the bottom of the sheet. When the user taps one of your buttons, WatchKit dismisses the sheet automatically and executes your button’s handler block. You can also dismiss the sheet programmatically by calling the
WKAlert style, this method automatically includes a localized Cancel button at the top of the sheet if you do not specify one in the
actions array. If one of your buttons is configured to be a Cancel button—that is, you initialize it with the
WKAlert style—the sheet displays your button’s text in place of the default Cancel button text.
Only one action or alert sheet may be visible at a time. If you call this method and a sheet is already visible, this method dismisses the previous sheet before displaying the new one.