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
modalInPopoverproperty - 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
passThroughViewsproperty -
This matters only if
modalInPopoveris 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). IfpassThroughViewsis 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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access