iOS Developer Library

Developer

UIKit Framework Reference UIPreviewAction Class Reference

Options
Deployment Target:

On This Page
Language:

UIPreviewAction

A preview action, or peek quick action, is displayed below a peek when a user swipes the peek upward. A peek quick action typically selects a deep link to your app and has a title, a style, and a handler.

Peeks and peek quick actions are available on devices that support 3D Touch.

  • Creates a peek quick action using a specified title, style, and handler.

    Declaration

    Swift

    convenience init(title title: String, style style: UIPreviewActionStyle, handler handler: (UIPreviewAction, UIViewController) -> Void)

    Objective-C

    + (instancetype)actionWithTitle:(NSString *)title style:(UIPreviewActionStyle)style handler:(void (^)(UIPreviewAction *action, UIViewController *previewViewController))handler

    Parameters

    title

    The quick action’s title.

    style

    The quick action’s style. For a complete list of styles, see the UIPreviewActionStyle enumeration in UIPreviewActionItem Protocol Reference.

    handler

    A block that is called when the user selects the peek quick action. The block takes the following parameters:

    action

    The peek quick action selected by the user.

    previewViewController

    The view controller displayed as the peek.

    Return Value

    A newly-created peek quick action.

    Availability

    Available in iOS 9.0 and later.

    See Also

    handler

  • The block called when the peek quick action is selected by the user. (read-only)

    Declaration

    Swift

    var handler: (UIPreviewActionItem, UIViewController) -> Void { get }

    Objective-C

    @property(nonatomic, copy, readonly, nonnull) void (^handler)(id<UIPreviewActionItem> action, UIViewController *previewViewController)

    Discussion

    The handler is set when the peek quick action is instantiated; it is immutable.

    Availability

    Available in iOS 9.0 and later.