Dismissing a Popover

An important feature of a popover’s configuration is whether and to what extent the user can operate outside it without automatically dismissing it. There are two aspects to this configuration:

UIViewController’s modalInPopover property
If this is YES for the popover controller’s view controller (or for its current view’s controller, as in a tab bar interface or navigation interface), the popover is absolutely modal; any tap outside it will be ignored — such a tap won’t have any effect at all, not even to dismiss the popover. The default is NO.
UIPopoverController’s passThroughViews property
This matters only if modalInPopover is NO. It is an array of views in the interface behind the popover; the user can interact with these views, but a tap anywhere else outside the popover will dismiss it (with no effect on the thing tapped). If passThroughViews is nil, a tap anywhere outside the popover will dismiss it.

Warning

Setting a UIPopoverController’s passThroughViews might not have any effect unless the popover is already showing (the UIPopoverController has been sent presentPopover...).

A popover can present a modal view internally; specify a modalPresentationStyle of UIModalPresentationCurrentContext (and a transition style of UIModalTransitionStyleCoverVertical), because otherwise the modal view will be fullscreen by default. A modal view’s modalInPopover is effectively YES; while it is showing, the user can’t make anything happen by tapping outside the popover, ...

Get Programming iOS 4 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.