About Document Interaction
iOS provides technologies for displaying previews of files that your app doesn’t directly support. iOS also provides a systemwide registry of file type associations, allowing your app to handle the opening of files from other installed apps. These powerful technologies include the
UIDocumentInteractionController class from the UIKit framework, described in UIDocumentInteractionController Class Reference, and the Quick Look framework, described in Quick Look Framework Reference for iOS.
Starting in iOS 4.2, the Quick Look framework provides built-in printing support for many document types. If you want to provide customized printing and copying, you can add that support to a document interaction controller by implementing methods in its delegate.
For code that demonstrates use of the
QLPreviewController classes, view the DocInteraction sample code project.
Previewing a Document or Presenting Options
Use a document interaction controller (an instance of the
UIDocumentInteractionController class) to provide users with options for working with files that your application doesn’t directly support, such iWork documents, PDF files, image files, and so on. A document interaction controller can modally present a file preview, and can present a menu containing various options for using the file—such as for opening it in another application or printing the file using AirPrint.
Registering Your Support of File Types
If your app can open specific file types, you can register that capability in your Xcode project’s
Info.plist file. When another application asks the system for help opening an item of those types, your application will be included in the options menu presented to the user.
Opening Files From Other Apps
The system may ask your app to open a specific file and present it to the user. This typically occurs because another app encountered a file of a type that you have registered to support. In this scenario, the system provides your app with a URL to the file and brings your app to the foreground.
Displaying and Printing Quick Look Previews
To gain even more control over file previews, you can use the Quick Look framework directly. You can choose the style of animation to use when presenting a preview, and can preview a list of items as well as a single item. A Quick Look preview controller also provides built-in AirPrint printing of supported file types.
© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-11-15)