What methods are available to view files on iPhone?
I am working on a hobby app which accesses the dropbox api and allows users to browse the directory structure (mimicking the Dropbox iPhone app).
开发者_开发问答My current challenge is to be able to view the files on the device. What is my best way of doing this? There are obviously a large range of file types and I would like to be able to view as many as possible. Further to this, does anyone know how to implement 'Open with' functionality that displays a list of compatible apps that can be opened to view the file externally.
Typical file types will include (but are not limited to)
- PDFs
- Images
- Documents
- Spreadsheets
- Presentations
- Video files
- Audio files
- Plain text
I understand that I may have to use different view controllers depending on the file type, but am sure that I have read before that there is a special view controller that can handle a lot of these file types. Just cannot find it for the life of me.
Also, I think I can use a UIWebView for a lot of the file types - though this seems like more of a work around than a definitive solution.
Before people ask, I am not intending to release this to the app store, but am trying to replicate the Dropbox app functionality for educational reasons.
Thanks
UIDocumentInteractionController, available on iOS 3.2 and upwards, is the way to do the "Open with" type functionality:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html#//apple_ref/occ/cl/UIDocumentInteractionController
The iOS application programming guide is the place I normally flick through to find things like that:
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StandardBehaviors/StandardBehaviors.html#//apple_ref/doc/uid/TP40007072-CH4-SW22
精彩评论