A specialized view for previewing an item.


class QLPreviewController : UIViewController


A displayed preview includes a title taken from the last path component of the item URL. You can override this by implementing a previewItemTitle accessor for the preview item.

A QLPreviewController can display previews for the following items:

  • iWork documents

  • Microsoft Office documents (Office ‘97 and newer)

  • Rich Text Format (RTF) documents

  • PDF files

  • Images

  • Text files whose uniform type identifier (UTI) conforms to the public.text type (see Uniform Type Identifiers Reference)

  • Comma-separated value (csv) files

  • 3D models in USDZ format (with both standalone and AR views for viewing the model)

A QLPreviewController can be presented modally (that is, full-screen) by calling present(_:animated:completion:) from a presenting UIViewController, or it can be pushed into view using a UINavigationController.

To use a Quick Look preview controller, you must provide a data source object. The data source provides preview items to the controller and tells it how many items to include in a preview navigation list. If there is more than one item in the list, a modally-presented controller displays navigation arrows to let the user switch among the items. For a Quick Look preview controller pushed using a navigation controller, you can provide buttons in the navigation bar for moving through the navigation list.

For details on providing items to a preview controller, refer to QLPreviewControllerDataSource and QLPreviewItem.


Configuring a Quick Look Preview Controller

var dataSource: QLPreviewControllerDataSource?

The Quick Look preview controller’s data source.

var delegate: QLPreviewControllerDelegate?

The Quick Look preview controller’s delegate object.

Managing Item Previews

class func canPreview(QLPreviewItem) -> Bool

Indicates whether or not the Quick Look preview controller can display an item.

var currentPreviewItem: QLPreviewItem?

The item currently displayed in the Quick Look preview controller.

var currentPreviewItemIndex: Int

The index, within the preview item navigation list, of the item currently displayed in the Quick Look preview controller.

func refreshCurrentPreviewItem()

Asks the Quick Look preview controller to recompute the display of the current preview item.

func reloadData()

Asks the Preview Controller to reload its data from its data source.