Protocol

QLPreviewControllerDelegate

The delegate of a preview controller must adopt this protocol.

Declaration

protocol QLPreviewControllerDelegate

Overview

The delegate of a QLPreviewController object must adopt this protocol to:

  • Provide a zoom animation for Quick Look previews.

  • Specify whether or not your application opens a URL that the user taps in a preview.

  • Respond to the opening or closing of a preview.

The methods described here are optional but expected.

Topics

Responding to Preview Requests

func previewController(QLPreviewController, frameFor: QLPreviewItem, inSourceView: AutoreleasingUnsafeMutablePointer<UIView?>) -> CGRect

Tells the delegate that the preview is about to be presented full screen or dismissed, to provide a zoom effect.

func previewController(QLPreviewController, transitionImageFor: QLPreviewItem, contentRect: UnsafeMutablePointer<CGRect>) -> UIImage?

Tells the delegate that the preview is about to be presented full screen or dismissed, to provide a smooth transition when zooming.

func previewController(QLPreviewController, transitionViewFor: QLPreviewItem) -> UIView?

Tells the delegate that the preview is about to be presented in full screen or dismissed, to provide a smooth transition when zooming.

func previewControllerWillDismiss(QLPreviewController)

Tells the delegate that the preview is about to close.

func previewControllerDidDismiss(QLPreviewController)

Tells the delegate that the preview was closed.

Responding to User Actions

func previewController(QLPreviewController, shouldOpen: URL, for: QLPreviewItem) -> Bool

Tells the delegate that the preview controller is trying to open a URL.

Editing the Content of a Preview

func previewController(QLPreviewController, editingModeFor: QLPreviewItem) -> QLPreviewItemEditingMode

Returns a value that indicates how the preview controller handles edits to the content of the previewed file.

enum QLPreviewItemEditingMode

A set of values that represent the different modes for editing a file.

func previewController(QLPreviewController, didUpdateContentsOf: QLPreviewItem)

Tells the delegate that the content of a preview was updated successfully.

func previewController(QLPreviewController, didSaveEditedCopyOf: QLPreviewItem, at: URL)

Tells the delegate that the preview item’s edited content was successfully saved to a copy at the given URL.

Relationships

Inherits From

See Also

Configuring a Preview Controller

var dataSource: QLPreviewControllerDataSource?

The preview controller’s data source.

protocol QLPreviewControllerDataSource

The data source for a preview controller must adopt this protocol to provide preview items to the controller.

var delegate: QLPreviewControllerDelegate?

The preview controller’s delegate object.