Contents

presentationSourceItem

The item you can use as an anchor for subsequent presentations.

Declaration

var presentationSourceItem: (any UIPopoverPresentationControllerSourceItem)? { get }

Discussion

The system populates this property during the execution of the menu element’s action (its handler or selector). For example, for a menu element in a menu that presents from a UIButton, the system may populate this property with that button.

Use this property to specify where to anchor popovers when a person taps the menu element, like in the following code.

let share = UIAction(title: "Share") { [unowned self] action in
    let shareVC = UIActivityViewController(activityItems: items, applicationActivities: activities)
    shareVC.modalPresentationStyle = .popover
    shareVC.popoverPresentationController?.sourceItem = action.presentationSourceItem
    present(shareVC, animated: true)
}

See Also

Managing the appearance