Presenting Modal UIViewControllers

Sometimes we want one controller to take up the entire screen to get a user’s attention. For example, Mailapp’s New Message screen appears on top of the usual inbox list, forcing the user to either complete the message or explicitly end the task. To accomplish this, we present the controller modally.

UIViewControllers allows us to present modal view controllers at any point in their life cycle. The key method is presentViewController:animated:completion:, which functions similarly to UINavigationController’s pushViewController:animated:. The given controller will be presented above all other controllers in the app and will remain there until we invoke dismissViewControllerAnimated:completion:.

Let’s present ...

Get RubyMotion 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.