Chapter 13. Modal Dialogs

A modal dialog demands attention; while it is present, the user can do nothing other than work within it or dismiss it. You might need to put up a simple modal dialog in order to give the user some information or to ask the user how to proceed. iOS provides two types of rudimentary modal dialog — alerts and action sheets.

A local notification is an alert that the system presents at a predetermined time on your app’s behalf when your app isn’t frontmost. I discuss local notifications in this chapter as well. I’ll also talk about today extensions, a mechanism whereby your app can present interface on the Today side of the device’s notification center.

An activity view is a modal dialog displaying icons representing possible courses of action, and intended in certain circumstances to replace the action sheet. For example, Mobile Safari’s Share button presents an activity view whose icons represent possible operations on a URL, such as handing it off to Mail, Message, or Twitter, or saving it internally as a bookmark or reading list item. I’ll describe how to present an activity view and how to provide your own activities, either privately within your app or publicly as an action extension or share extension.

Alerts and Action Sheets

Alerts and action sheets are both forms of presented view controller. They are managed through the UIAlertController class, a UIViewController subclass. To show an alert or an action sheet is a three-step process:

  1. Instantiate UIAlertController ...

Get Programming iOS 9 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.