Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Quick Look for iOS

Quick Look for iOS

Ever wanted to preview files like Apple's Mail app does? Quick Look is an Apple framework that lets you do just that.

Rob Brown

March 10, 2011
Tweet

More Decks by Rob Brown

Other Decks in Programming

Transcript

  1. QLPreviewItem Protocol for previewing files (Required) -(NSURL)previewItemURL Must be a

    file URL (i.e. file://somefile.txt) Use [NSURL fileURLWithPath:somePath] (Optional) -(NSString)previewItemTitle NSURL conforms to QLPreviewItem
  2. QLPreviewController Subclass of UIViewController Can be pushed into view or

    presented modally Must have a data source May have a delegate
  3. QLPreviewControllerDelegate Provides call backs for when the view will dismiss

    and did dismiss Provides a couple animation call backs One call back asking permission to open URLs
  4. UIDocumentInteractionController Manages user interactions with files on the local system

    More control than QLPreviewController Only previews one file Provides easy access to a file’s icons Provides access to annotation property for passing custom data with a file
  5. Inter-app File Sharing Files aren’t “shared,” they are copied into

    the app’s sandbox (~Documents/Inbox) An app’s Info.plist specifies which files are accepted with the CFBundleDocumentTypes key CFBundleDocumentTypes is an array of dictionaries
  6. Inter-app File Sharing CFBundleDocumentTypes sub keys: CFBundleTypeName: Name of the

    type CFBundleTypeIconFiles: array of icons (smallest to largest) LSItemContentTypes: array of UTIs LSHandlerRank: Owner, Alternate, None, Default
  7. Inter-app File Sharing LSHandlerRank (in order of precedence): Owner: Creator

    of these files Alternate: Secondary viewer None: Files can only be loaded through iTunes Default: Accepts files