Class

UIPopover​Controller

Important: UIPopover​Controller is deprecated in iOS 9. In iOS 9 and later, a popover is implemented as a UIView​Controller presentation. To create a popover, use an instance of UIPopover​Presentation​Controller and specify the popover style.

Overview

The UIPopover​Controller class is used to manage the presentation of content in a popover. You use popovers to present information temporarily. The popover content is layered on top of your existing content and the background is dimmed automatically. The popover remains visible until the user taps outside of the popover window or you explicitly dismiss it. Popover controllers are for use exclusively on iPad devices. Attempting to create one on other devices results in an exception.

To display a popover, create an instance of this class and present it using one of the appropriate methods. When initializing an instance of this class, you must specify the view controller that provides the content for the popover. Popovers normally derive their size from the view controller they present. However, you can change the size of the popover by modifying the value in the content​Size property or by calling the set​Content​Size(_:​animated:​) method. The latter approach is particularly effective if you need to animate changes to the popover’s size. The size you specify is just the preferred size for the popover’s view. The actual size may be altered to ensure that the popover fits on the screen and does not collide with the keyboard.

When displayed, taps outside of the popover window cause the popover to be dismissed automatically. To allow the user to interact with the specified views and not dismiss the popover, you can assign one or more views to the passthrough​Views property. Taps inside the popover window do not automatically cause the popover to be dismissed. Your view and view controller code must handle actions and events inside the popover explicitly and call the dismiss(animated:​) method as needed.

If the user rotates the device while a popover is visible, the popover controller hides the popover and then shows it again at the end of the rotation. The popover controller attempts to position the popover appropriately for you but you can also implement the popover​Controller(_:​will​Reposition​Popover​To:​in:​) method in the popover delegate to specify a new position.

You can assign a delegate to the popover to manage interactions with the popover and receive notifications about its dismissal. For information about the methods of the delegate object, see UIPopover​Controller​Delegate.

Symbols

Initializing the Popover

init(content​View​Controller:​ UIView​Controller)

Returns an initialized popover controller object.

Presenting and Dismissing the Popover

Configuring the Popover Content

var content​View​Controller:​ UIView​Controller

The view controller responsible for the content portion of the popover.

func set​Content​View(UIView​Controller, animated:​ Bool)

Sets the view controller responsible for the content portion of the popover.

var content​Size:​ CGSize

The size of the popover’s content view.

func set​Content​Size(CGSize, animated:​ Bool)

Changes the size of the popover’s content view.

var passthrough​Views:​ [UIView]?

An array of views that the user can interact with while the popover is visible.

Getting the Popover Attributes

var is​Popover​Visible:​ Bool

A Boolean value indicating whether the popover is currently visible.

var arrow​Direction:​ UIPopover​Arrow​Direction

The direction of the popover’s arrow.

Accessing the Delegate

var delegate:​ UIPopover​Controller​Delegate?

The delegate you want to receive popover controller messages.

Customizing the Popover Appearance

var layout​Margins:​ UIEdge​Insets

The margins that define the portion of the screen in which it is permissible to display the popover.

var background​View​Class:​ Any​Class?

The class to use for displaying the popover background content.

var background​Color:​ UIColor?

The color of the popover’s backdrop view.

Constants

UIPopover​Arrow​Direction

Constants for specifying the direction of the popover arrow.