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:
Push it into view using a
UINavigationController
object.Present it modally, full screen, using the
presentModalViewController:animated:
method of its parent class,UIViewController
.Present a document interaction controller (as described in Previewing and Opening Files. The user can then invoke a Quick Look preview controller by choosing Quick Look from the document interaction controller’s options menu.
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 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 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.
Copyright © 2010 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2010-11-15