QLPreviewController Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/QuickLook.framework
Availability
Available in iOS 4.0 and later.
Declared in
QLPreviewController.h
Related sample code

Overview

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:

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.

Tasks

Configuring a Quick Look Preview Controller

Managing Item Previews

Properties

currentPreviewItem

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

@property (readonly) id<QLPreviewItem> currentPreviewItem
Discussion

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

Availability
  • Available in iOS 4.0 and later.
Declared In
QLPreviewController.h

currentPreviewItemIndex

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

@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.

Availability
  • Available in iOS 4.0 and later.
Related Sample Code
Declared In
QLPreviewController.h

dataSource

The Quick Look preview controller’s data source.

@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.

Availability
  • Available in iOS 4.0 and later.
Related Sample Code
Declared In
QLPreviewController.h

delegate

The Quick Look preview controller’s delegate object.

@property (assign) id delegate
Discussion

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

Availability
  • Available in iOS 4.0 and later.
Related Sample Code
Declared In
QLPreviewController.h

Class Methods

canPreviewItem:

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

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

An item to be previewed.

Return Value

Returns YES 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.

Availability
  • Available in iOS 4.0 and later.
Declared In
QLPreviewController.h

Instance Methods

refreshCurrentPreviewItem

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

- (void) refreshCurrentPreviewItem
Discussion

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

Availability
  • Available in iOS 4.0 and later.
Declared In
QLPreviewController.h

reloadData

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

- (void) reloadData
Discussion

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

Availability
  • Available in iOS 4.0 and later.
Declared In
QLPreviewController.h