I'm writing an iPad application that has a UIWebView which I open word and excel documents in, but I want the user to be able to import those documents into the iWorks applications, Pages and Numbers, just like how you can do it in Safari if you open a document.
If you open a document开发者_运维问答 in Safari on the iPad, there'll be a button on the top bar that says "Open in..." and you can choose applications to open in. You get the top bar to appear by tapping on middle of the page.
So is there an option you can set to allow UIWebView to show up the bar and automatically detect the content type and populate the list with applications you can import in? Or do I have to build this myself? And if I have to build my own, how do I open URLs to import documents into Pages and Numbers etc?
Thanks, -David
AFAIK, UIWebView does not offer any functionality of this kind. You should use a UIDocumentInteractionController
, which is designed for exactly this purpose. From the docs:
The UIDocumentInteractionController class provides in-application support for managing user interactions with files in the local system. For example, a mail program might use this class to allow the user to preview and open attachments inline with a mail message. You use this class to present the user with an appropriate interface for previewing, opening, or copying the specified file.
精彩评论