What is a modal view?

eugene picture eugene · Mar 16, 2011 · Viewed 16.4k times · Source

I wanted to do bottom-up or up-bottom animation for settings page. (which would normally be pushViewController)
And found out that bottom-up can be done with..

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated;

Some people seem to suggest that you stick to Apple's HIG (Apple surely made left-right animation as default pushViewController) and do not use modal view.

I wonder what is modal view and wonder what other animations people use for pushing/popping viewController?

Thank you.

Answer

James Bedford picture James Bedford · Mar 16, 2011

A modal view prevents interaction with any other UI until it is dismissed.

A modal view controller is simply a UIViewController class that is presented modally. When the view controller is presented modally it covers whatever the existing view was (using an animation if specified) and the user most somehow dismiss this view before they can return to what they were doing.

To present a view controller in a modal fashion, you can use the method:

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated;

Whenever I want to use a modal view (i.e. a view that must be completed before continuing with anything else) I would call this method and use Apple's standard animation for presenting a view controller (notice that the instance method above does not include a parameter to specify how the view is animated - because Apple has a standard way of doing this).