Class

QLPreviewController

A specialized view controller for previewing an item.

Declaration

@interface QLPreviewController : UIViewController

Overview

A QLPreviewController can display previews for many common file types, including the following:

  • iWork documents

  • Microsoft Office documents

  • Rich Text Format, or RTF, documents

  • PDF files

  • Images

  • Text files with a uniform type identifier (UTI) that conforms to the public.text type. To learn more about UTIs, see the Uniform Type Identifiers Reference.

  • Comma-separated value, or CSV, files

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

On iOS devices, you can present a QLPreviewController modally by calling presentViewController:animated:completion: from a presenting UIViewController, or you can push it into view using a UINavigationController. The preview includes a title taken from the last path component of the item URL. You can override it by implementing a previewItemTitle accessor for the preview item.

To use a 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’s more than one item in the list, a modally presented controller displays navigation arrows to let the user switch among the items. If you pushed a preview controller into view 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, see QLPreviewControllerDataSource and QLPreviewItem.

Topics

Configuring a Preview Controller

dataSource

The preview controller’s data source.

QLPreviewControllerDataSource

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

delegate

The preview controller’s delegate object.

QLPreviewControllerDelegate

The delegate of a preview controller must adopt this protocol.

Managing Item Previews

+ canPreviewItem:

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

currentPreviewItem

The item currently displayed in the Quick Look preview controller.

currentPreviewItemIndex

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

- refreshCurrentPreviewItem

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

- reloadData

Asks the preview controller to reload its data from its data source.

Relationships

Inherits From

See Also

Previews and Thumbails

QLPreviewItem

A protocol that defines properties you implement to make your application’s content visible in a preview.

QLPreviewingController

A protocol for implementing a custom controller to create previews of files.

Previews or Thumbnail Images for macOS 10.14 or Earlier

Create thumbnail images or previews of common files and custom file types on earlier versions of macOS.