Recipe: Modal Presentation

With normal navigation controllers, you push your way along views, stopping occasionally to pop back to previous views. That approach assumes that you’re drilling your way up and down a set of data that matches the tree-based view structure you’re using. Modal presentation offers another way to show a view controller.

After you send the presentViewController:animated:completion: message to a view controller, the specified view controller appears on the screen and takes control until it’s dismissed with dismissViewControllerAnimated:completion:. This enables you to add special-purpose dialogs to your applications that go beyond alert views.

Typically, modal controllers prompt users to pick data such as contacts from ...

Get The Core iOS Developer’s Cookbook, Fifth 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.