Using the Quick Look Framework

To gain even more control over file previews, you can use the Quick Look framework directly. The framework’s primary class is QLPreviewController. It relies on a delegate for responding to preview actions, and on a data source for providing the preview items.

In iOS 4.2 and later, the specialized view presented by a Quick Look preview controller includes an action button with a Print item. If the controller can provide a preview of a file, it can also print it. There is no printing code for you to write.

To display a Quick Look preview controller you can use any of these options:

When presenting a Quick Look preview controller yourself, choose the display option that best fits the visual and navigation style of your application. Modal, full-screen display might work best if your app doesn’t use a navigation bar. If your app uses iPhone-style navigation, you might want to opt for pushing your preview into view.

A displayed preview includes a title taken from the last path component of the item URL. You can override this by implementing a previewItemTitleaccessor 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 using the methods described in QLPreviewControllerDataSource Protocol Reference. 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 preview-item list.

For a complete description of the Quick Look framework, see Quick Look Framework Reference for iOS.