Class

UIContextMenuInteraction

An interaction object that you use to display relevant actions for your content.

Declaration

class UIContextMenuInteraction : NSObject

Overview

Use a UIContextMenuInteraction object to focus the user's attention on a specific portion of your content, and to provide actions for the user to perform on that content. A context menu interaction object tracks Force Touch gestures on devices that support 3D Touch, and long-press gestures on devices that don't support it. When the appropriate gesture occurs, this object animates your content to a new interface and displays the contextual menu that you supplied. UIKit manages all menu-related interactions and reports the selected action, if any, back to your app.

A context menu interaction object inherits from UIInteraction. After creating the object, assign an appropriate object to its delegate property and use the addInteraction(_:) method to attach it to one of your views. The delegate object you provide must adopt the UIContextMenuInteractionDelegate protocol. Use the methods of that object to provide the contents of the contextual menu. Add your context menu interaction object to a view in your interface using the view's addInteraction(_:) method.

Topics

Creating a Context Menu Interaction Object

init(delegate: UIContextMenuInteractionDelegate)

Creates a context menu interaction object with the specified delegate object.

Previewing and Managing the Content

var delegate: UIContextMenuInteractionDelegate?

The object that provides the preview and contextual menu for your content and responds to interaction-related events.

protocol UIContextMenuInteractionDelegate

The methods for providing the set of actions to perform on your content, and for customizing the preview of that content.

Getting the Interaction's Location

func location(in: UIView?) -> CGPoint

Returns the location of the user interaction in the specified view's coordinate system.

Relationships

Inherits From

See Also

Contextual Menus

protocol UIContextMenuInteractionDelegate

The methods for providing the set of actions to perform on your content, and for customizing the preview of that content.

Beta
class UITargetedPreview

An object describing the view to use during preview-related animations.

Beta
class UIPreviewTarget

An object that specifies the container view to use for animations.

Beta
class UIPreviewParameters

Additional parameters to use when animating a preview interface.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software