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. Two UIView subclasses, UIAlertView and UIActionSheet, construct and present rudimentary modal dialogs.

One sees occasionally a misuse of the built-in dialogs to include additional interface. For example, a UIActionSheet is a UIView, so in theory you can add a subview to it. I cannot recommend such behavior; it clearly isn’t intended, and there’s no need for it. If what you want isn’t what a built-in dialog normally does, don’t use a built-in dialog. I’ll suggest some alternatives later.

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. This alert can generate a UIAlertView, so I discuss it in this chapter as well.

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.

In iOS 7, an alert view, an action sheet, and an activity view all interpose a “through a glass darkly” shadow view between themselves ...

Get Programming iOS 7, 4th Edition 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.