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 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 presents an activity view from its Action button; the icons represent external modes of sharing a URL such as Mail, Message, and Twitter, as well as internal actions such as Bookmark and Add to Reading List. 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.

Alerts and Action Sheets

New in iOS 8, alerts and action sheets are both forms of presented view controller. They are managed through the UIAlertController class, a UIViewController subclass. (This architecture replaces that of iOS 7 and before, where alerts and action sheets were ...

Get Programming iOS 8 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.