際際滷

際際滷Share a Scribd company logo
Quick Look for iOS
By Robert Brown
@robby_brown
What is Quick Look?


Previews all common 鍖les
Includes AirPrint
Available since iOS 4.0
QLPreviewItem
Protocol for previewing 鍖les
(Required) -(NSURL)previewItemURL
  Must be a 鍖le URL (i.e. 鍖le://some鍖le.txt)
  Use [NSURL 鍖leURLWithPath:somePath]
(Optional) -(NSString)previewItemTitle
NSURL conforms to QLPreviewItem
QLPreviewController

Subclass of UIViewController
Can be pushed into view or presented modally
Must have a data source
May have a delegate
QLPreviewController
iWork Documents     Text 鍖les (with supported
                    UTI)
Microsoft Of鍖ce
Documents (1997+)   CSV
RTF                 HTML


PDF
Images
QLPreviewControllerDataSource



 Similar to UITableViewDataSource
 Tells how many QLPreviewItems it provides
 Returns a QLPreviewItem when asked
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
UIDocumentInteractionController

 Manages user interactions with 鍖les on the local system
 More control than QLPreviewController
 Only previews one 鍖le
 Provides easy access to a 鍖les icons
 Provides access to annotation property for passing
 custom data with a 鍖le
Inter-app File Sharing

 Files arent shared, they are copied into the apps
 sandbox (~Documents/Inbox)
 An apps Info.plist speci鍖es which 鍖les are accepted
 with the CFBundleDocumentTypes key
 CFBundleDocumentTypes is an array of dictionaries
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
Inter-app File Sharing

 LSHandlerRank (in order of precedence):
   Owner: Creator of these 鍖les
   Alternate: Secondary viewer
   None: Files can only be loaded through iTunes
   Default: Accepts 鍖les
Inter-app File Sharing



 Developer tip: Use mdls command on a 鍖le to see its
 UTI tree
Questions?
Demo
Want to learn more?


robsprogramknowledge.blogspot.com
Document Interaction Programming Topics for iOS
WWDC 2010 Session 106

More Related Content

Quick Look for iOS

  • 1. Quick Look for iOS By Robert Brown @robby_brown
  • 2. What is Quick Look? Previews all common 鍖les Includes AirPrint Available since iOS 4.0
  • 3. QLPreviewItem Protocol for previewing 鍖les (Required) -(NSURL)previewItemURL Must be a 鍖le URL (i.e. 鍖le://some鍖le.txt) Use [NSURL 鍖leURLWithPath:somePath] (Optional) -(NSString)previewItemTitle NSURL conforms to QLPreviewItem
  • 4. QLPreviewController Subclass of UIViewController Can be pushed into view or presented modally Must have a data source May have a delegate
  • 5. QLPreviewController iWork Documents Text 鍖les (with supported UTI) Microsoft Of鍖ce Documents (1997+) CSV RTF HTML PDF Images
  • 6. QLPreviewControllerDataSource Similar to UITableViewDataSource Tells how many QLPreviewItems it provides Returns a QLPreviewItem when asked
  • 7. 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
  • 8. UIDocumentInteractionController Manages user interactions with 鍖les on the local system More control than QLPreviewController Only previews one 鍖le Provides easy access to a 鍖les icons Provides access to annotation property for passing custom data with a 鍖le
  • 9. Inter-app File Sharing Files arent shared, they are copied into the apps sandbox (~Documents/Inbox) An apps Info.plist speci鍖es which 鍖les are accepted with the CFBundleDocumentTypes key CFBundleDocumentTypes is an array of dictionaries
  • 10. 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
  • 11. Inter-app File Sharing LSHandlerRank (in order of precedence): Owner: Creator of these 鍖les Alternate: Secondary viewer None: Files can only be loaded through iTunes Default: Accepts 鍖les
  • 12. Inter-app File Sharing Developer tip: Use mdls command on a 鍖le to see its UTI tree
  • 14. Demo
  • 15. Want to learn more? robsprogramknowledge.blogspot.com Document Interaction Programming Topics for iOS WWDC 2010 Session 106

Editor's Notes