UIDocumentInteractionController
我有一个问题让我发疯。
在我的应用程序中,当显示 OpenIn 菜单时,我将选择一个应用程序来打开文件(例如:DocsToGo),然后打开文档进行编辑。
但是编辑后,如何将其发送回我的应用程序或获取保存该文档的链接?我怎样才能获得该文件的新内容?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的应用程序无法访问文件的更改版本。新版本驻留在您发送到的应用程序的沙箱中。将文件恢复到应用程序中的唯一方法是,您的应用程序注册为可以打开该文档类型的应用程序。那么您必须希望其他应用程序为用户提供在另一个应用程序中打开新文件的选项。
另一种选择是使用第三方云服务来存储文档。现在许多应用程序都与 Dropbox 集成。如果您的应用程序和 DocsToGo 都使用 Dropbox,那么您将能够编辑同一文档并访问它。
简而言之:您的应用程序不支持将文档发送到另一个应用程序,然后在进行更改后将其拉回的方式。
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.
正如 Mark Suman 在他的回答中提到的那样,您的应用程序无法“拉取”已更改的文件,但是如果用户使用类似的“在...中打开”命令将其从其他应用程序推送回给您,您可以实现一个工作流程文件从您的应用程序传递到另一个应用程序并再次传递回来。当文件发送回您的应用程序时,它会触发应用程序委托中的 application:handleOpenURL: 方法(或 iOS 4.2+ 中的 application:openURL:sourceApplication:annotation: )。 URL 参数是已编辑文件的 URL,您的应用程序随后可以继续使用该文件。
更多信息请参见此处。
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.