Popover Segues

In an iPad storyboard, a segue can be designated a popover segue, by choosing Popover from the Style pop-up menu in the Attributes inspector. The consequences of doing so are:

  • When the segue is triggered, a popover is displayed. The runtime constructs a UIPopoverController and makes the segue’s destination view controller the UIPopoverController’s content view controller. The popover’s “anchor” (the view or bar button item to which its arrow points) is the source object from which you control-drag to form the segue, or it can be set in the Attributes inspector.
  • The segue is a UIStoryboardPopoverSegue, a UIStoryboardSegue subclass that adds a single read-only property, popoverController. You can use this, for instance, in prepareForSegue:sender:, to customize the popover controller.
  • An unwind segue from within the popover’s content view controller dismisses the popover.

The UIPopoverController created by the triggering of a popover segue is retained behind the scenes; the app does not crash if you fail to retain it explicitly yourself. Nevertheless, you may still wish to retain your own reference to the popover controller, in order to know that a popover is being displayed, in order to dismiss it in code, and so forth. You’ll probably obtain that reference in your prepareForSegue:sender: implementation.

Popover segues sound tempting, but they do not appreciably reduce the amount of code required to configure and manage a popover. Consider, for example, the code I ...

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.