Modal Navigation

Modal view controllers take over the entire screen and block all other navigation in the application until they are dismissed.

Modal segues are created similarly to hierarchical push segues, by control-dragging from an actionable object in one view controller, like a button, to another view controller. They can also be created in code using presentViewController:animated:completion:.

Header Source

By default, modal views animate by sliding from the bottom, covering the current view, but you can change that in the Storyboard if you need to.

Modal views are dismissed by calling dismissViewControllerAnimated:completion: on the presenting view controller, not on the presented modal view controller.

You usually do not want a modal view controller dismissing itself, but if you need to do so, you can use its presentingViewController property.

Header Source

The preferred way to dismiss a modal view is using delegation. When the modal view controller is finished, it reports back to its delegate (usually the presenter). It is then up to the delegate/presenter to dismiss the modal view.

Header Source

It is usually a good idea to make sure the delegate is set, and that it responds to the method we’re calling on it before proceeding.

Comments are closed.