In my app, my root view is a grid view with cells. When I tap a particular cell, the modal view controller will pop up with details of that particular cell.
How can I fade out the grid view when my modal view is present?
Also, how can I dismiss the modal view when I tap anywhere in the grid view, which is behind my modal view?
iOS 5 brought in a new UIViewController method,
presentViewController:animated:completion:(documentation linked for you) and of course you probably already know aboutpresentModalViewController:animated:(documentation says to use thepresentViewControllermethod in place of the olderpresentModalViewController, but this depends on if you are supporting iOS 5 & newer only).You can set animated to YES and use a fade animation, or set the parent view’s alpha closer to 0.0 (to “fade” it somewhat).
The
UIViewdocumentation has some notes about fading things, including some sample code. Look atanimateWithDuration:animations:completion:As for dismissing the modal view, wouldn’t
dismissModalViewControllerAnimated:work?