UIDocumentInteractionController

2019-07-25 10:35发布

问题:

I have a problem that make me crazy.

From my app, when an OpenIn menu is shown, I'll choose an application to open the file (ex:DocsToGo) and the document is opened for edit.

But after editing, how can I send it back to my app or get the link where that document is saved ? How can I get new content of that file ?

回答1:

Your app cannot get access to the changed version of the file. The new version resides within the sandbox of the app to which you sent it. The only way you can get the file back into your app is if your app registers as an application that can open that document type. THEN you have to hope that the other application gives the user the option to open the new file in another application.

Another option is to use a third party cloud service for storing the documents. Many apps integration with Dropbox now. If your app and DocsToGo both used Dropbox, then you would be able to both edit the same document and get access to it.

In short: there is no Apple-supported way for your app to send a document to another app and then pull it back after changes have been made.



回答2:

Your app can't "pull" the changed file, as Mark Suman mentioned in his answer, but if the user pushes it back to you from the other app with a similar "open in..." command, you can implement a workflow where a file is passed from your app to another and back again. When the file is sent back to your app, it triggers the application:handleOpenURL: method in the app delegate (or application:openURL:sourceApplication:annotation: in iOS 4.2+). The URL argument is the URL of the edited file, which your app can then resume working with.

More info here.