Class

UIPreviewInteraction

A class that registers a view to provide a custom user experience in response to 3D Touch interactions.

Declaration

@interface UIPreviewInteraction : NSObject

Overview

A 3D Touch interaction results in a preview interaction that comprises two phases, the first also called preview, followed by commit. The interaction progresses through these phases as the user applies more force with a touch. Figure 1 shows the relationship between the force of the user's touch and the phases of the preview interaction.

Figure 1

Relationship between touch force and preview interaction phases

An illustration showing the preview interaction as it progresses through the preview phase and into the commit phases in response to increasing touch force.

When using view controller previewing, peek represents the preview phase, and pop the commit phase.

A preview interaction is responsible for managing 3D Touch interactions for a specified view. It uses a delegate object to communicate the progress and status of the interaction to your code.

To use a preview interaction in your app:

  1. Create a UIPreviewInteraction object, passing the view into the default initializer.

  2. Create a delegate object that conforms to the UIPreviewInteractionDelegate protocol, and implement the appropriate methods.

  3. Assign the delegate object to the delegate property on the preview interaction object.

For more information about the state transitions through which a preview interaction progresses, see UIPreviewInteractionDelegate.

Topics

Preparing Preview Interactions

- initWithView:

Returns a newly initialized preview interaction for the specified view.

delegate

An object that acts as the delegate of the preview interaction.

Handling Preview Interactions

view

The view from which the preview interaction receives touch events.

- cancelInteraction

Cancels the current preview interaction.

- locationInCoordinateSpace:

Returns the location of the touch that started the interaction.

Relationships

Inherits From

See Also

3D Touch Interactions

UIPreviewInteractionDelegate

A set of methods for communicating the progress of a preview interaction.

UIPreviewActionItem

A set of methods that defines the styles you can apply to peek quick actions and peek quick action groups, and defines a read-only accessor for the user-visible title of a peek quick action.