An object that manages the display of content in a popover.
- iOS 8.0+
From the time a popover is presented until the time it is dismissed, UIKit uses an instance of this class to manage the presentation behavior. You use instances of this class as-is to configure aspects of the popover appearance and behavior for view controllers whose presentation style is set to
In nearly all cases, you use this class as-is and do not create instances of it directly. UIKit creates an instance of this class automatically when you present a view controller using the
popover style. You can retrieve that instance from the presented view controller’s
popover property and use it to configure the popover behavior.
If you do not want to configure a popover immediately after presenting a view controller, you can use a delegate object to configure the popover instead. During the presentation process, the popover presentation controller calls various methods of its delegate—an object that conforms to the
UIPopover protocol—to ask for information and to inform it about the state of the presentation. Your delegate object can use those methods to configure the popover and adjust its behavior as needed. For information about how to implement a delegate for a popover presentation controller, see
Configuring a View Controller for Display as a Popover
To display a popover, set the presentation style of your view controller to
popover, provide an anchor point, and call the
present(_: method. The view controller's
popover property contains the object that you use to configure the popover details.
Listing 1 shows an action method that displays a popover when a bar button item is tapped. After loading the view controller and setting its presentation style, the method assigns the bar button item to the popover presentation controller associated with the view controller.
Configure other properties of the popover presentation controller before calling the
present(_: method. For example, you might want to assign a delegate to manage the presentation and dismissal of the popover.