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:
-
UIPopoverController’s
passthroughViews
property -
This is an array of views in the interface behind the popover; the user can interact with these views while the popover is showing. What happens if the user taps a view that is not listed in the
passthroughViews
array depends on themodalInPopover
property. -
UIViewController’s
modalInPopover
property If this is YES for the popover controller’s view controller (or for its current child view controller, as in a tab bar interface or navigation interface), then if the user taps outside the popover on a view not listed in the popover controller’s
passthroughViews
, nothing at all happens.If it is NO (the default), then if the user taps outside the popover on a view not listed in the popover controller’s
passthroughViews
, the view tapped on is unaffected, and the popover is dismissed.
Warning
The claim made by the documentation (and by previous editions of this book) that modalInPopover
prevents all user interaction outside a popover is wrong. The user can still interact with a view listed in the passthroughViews
even if modalInPopover
is YES.
You should pay attention to the passthroughViews
, as the default behavior may be undesirable. For example, if a popover is summoned by the user tapping a UIBarButton item in a toolbar using ...
Get Programming iOS 6, 3rd Edition 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.