且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在同一个iOS设备中将文件从一个应用程序传输到另一个应用程序?

更新时间:2023-11-22 16:22:10

UIDocumentInteractionController

基本上它的工作原理如下:

Basically it works like this:


  1. 能够处理类型为XYZ的文件

  2. App 2实现 UIDocumentInteractionController ,并且将给用户选项将文件发送到App1 (我相信这必须是用户激活的)

  3. App 1 implements - (BOOL)application:openURL:sourceApplication:annotation:处理传输的文件,该文件将保存在您的 Documents / Inbox 目录中。从那里你可以复制文件在其他地方,然后处理它,确保你清理掉了保存在收件箱文件夹中的原始文件。

  1. App 1 registers as being able to handle files of type XYZ
  2. App 2 implements UIDocumentInteractionController and will give users the options to "send the file to App1" (I believe this has to be user activated)
  3. App 1 implements -(BOOL)application:openURL:sourceApplication:annotation: and deals with the transferred file which will be saved in your Documents/Inbox directory. From there you can copy the file elsewhere and then manipulated it, making sure you clean up by getting rid of the original one saved on the Inbox folder.

可供参考类别此处

可提供文档交互计划指南这里

Document interaction programming guide available here