iOS Developer Library — Pre-Release

Developer

QuickLook Framework Reference QLPreviewController Class Reference

Options
Deployment Target:

On This Page
Language:

QLPreviewController

Inheritance


Import Statement


Swift

import QuickLook

Objective-C

@import QuickLook;

Availability


Available in iOS 4.0 and later.

A QLPreviewController object, or Quick Look preview controller, provides a specialized view for previewing an item. To display a Quick Look preview controller you have two options: You can push it into view using a UINavigationController object, or can present it modally, full screen, using the presentModalViewController:animated: method of its parent class, 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 Quick Look preview controller 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

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 (that is, full-screen) 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 Protocol Reference and QLPreviewItem Protocol Reference for iOS.

  • The Quick Look preview controller’s data source.

    Declaration

    Swift

    unowned(unsafe) var dataSource: QLPreviewControllerDataSource!

    Objective-C

    @property(assign) id< QLPreviewControllerDataSource > dataSource

    Discussion

    To use a Quick Look preview controller, you must implement a data source. The data source is responsible for providing items for display by the controller, and for telling it how many items to include in the preview navigation list. It is described inQLPreviewControllerDataSource Protocol Reference.

    Import Statement

    Objective-C

    @import QuickLook;

    Swift

    import QuickLook

    Availability

    Available in iOS 4.0 and later.

  • delegate delegate Property

    The Quick Look preview controller’s delegate object.

    Declaration

    Swift

    unowned(unsafe) var delegate: QLPreviewControllerDelegate!

    Objective-C

    @property(assign) id< QLPreviewControllerDelegate > delegate

    Discussion

    The delegate determines whether or not to open URLs that the user taps in a preview. See QLPreviewControllerDelegate Protocol Reference.

    Import Statement

    Objective-C

    @import QuickLook;

    Swift

    import QuickLook

    Availability

    Available in iOS 4.0 and later.

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

    Declaration

    Swift

    class func canPreviewItem(_ item: QLPreviewItem!) -> Bool

    Objective-C

    + (BOOL)canPreviewItem:(id<QLPreviewItem>)item

    Parameters

    item

    An item to be previewed.

    Return Value

    Returns YEStrue if the Quick Look preview controller can display the specified preview item.

    Discussion

    If an item cannot be displayed, but you still attempt to display it, a Quick Look preview controller displays a generic error. Always check if an item can be displayed before choosing whether or not to display it.

    Refer to this document’s Overview section (QLPreviewController) for the types of items that a Quick Look preview controller can display.

    Import Statement

    Objective-C

    @import QuickLook;

    Swift

    import QuickLook

    Availability

    Available in iOS 4.0 and later.

  • The item currently displayed in the Quick Look preview controller. (read-only)

    Declaration

    Swift

    var currentPreviewItem: QLPreviewItem! { get }

    Objective-C

    @property(readonly) id< QLPreviewItem > currentPreviewItem

    Discussion

    If no item is being displayed, this property’s value is nil.

    Import Statement

    Objective-C

    @import QuickLook;

    Swift

    import QuickLook

    Availability

    Available in iOS 4.0 and later.

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

    Declaration

    Swift

    var currentPreviewItemIndex: Int

    Objective-C

    @property NSInteger currentPreviewItemIndex

    Discussion

    You can change which item is displayed, among those in a navigation list, by setting this property’s value. If no item is being displayed, this property’s value is NSNotFound.

    Import Statement

    Objective-C

    @import QuickLook;

    Swift

    import QuickLook

    Availability

    Available in iOS 4.0 and later.

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

    Declaration

    Swift

    func refreshCurrentPreviewItem()

    Objective-C

    - (void)refreshCurrentPreviewItem

    Discussion

    The display is recomputed whether or not the current preview item has changed.

    Import Statement

    Objective-C

    @import QuickLook;

    Swift

    import QuickLook

    Availability

    Available in iOS 4.0 and later.

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

    Declaration

    Swift

    func reloadData()

    Objective-C

    - (void)reloadData

    Discussion

    The display is recomputed only if the current preview item has changed.

    Import Statement

    Objective-C

    @import QuickLook;

    Swift

    import QuickLook

    Availability

    Available in iOS 4.0 and later.