iOS Apps间分享数据
发布日期:2022-03-18 08:27:37 浏览次数:42 分类:技术文章

本文共 2375 字,大约阅读时间需要 7 分钟。

iOS Apps间分享数据

请参考:

总的来说有如下几种:

  • UIDocumentInteractionController
  • UIActivityViewController
  • Shared Keychain Access
  • Custom URL Scheme
  • Web Service
  • UIPasteboard + URL Scheme

UIDocumentInteractionController

请参考:

UIDocumentInteractionController文档见

注册APP支持的文件类型(Registering the File Types Your App Supports)

在Info.plist中使用CFBundleDocumentTypes键,对应的为array,可以包括如下的key:

  • CFBundleTypeName specifies the name of the document type(文件类型).
  • CFBundleTypeIconFiles is an array of filenames for the image resources to use as the document’s icon(图标).
  • LSItemContentTypes contains an array of strings with the UTI types that represent the supported file types in this group(UTI数组).
  • LSHandlerRank describes whether this application owns the document type or is merely able to open it(是否拥有or仅仅是打开).

UTI类型请参考:

打开支持的文件类型(Opening Supported File Types)

The system may ask your application to open a specific file and present it to the user. This typically occurs because another application encountered the file and used a document interaction controller to handle it. You receive information about the file to be opened in the application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions: method of your application delegate. If your application handles custom file types, you must implement this delegate method (instead of the applicationDidFinishLaunching: method) and use it to initialize your application.

The options dictionary passed to the application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions: method contains information about the file to be opened. Specifically, your application should look in this dictionary for the following keys:

  • UIApplicationLaunchOptionsURLKey contains an NSURL object that specifies the file to open.
  • UIApplicationLaunchOptionsSourceApplicationKey contains an NSString with the bundle identifier of the application that initiated the open request.
  • UIApplicationLaunchOptionsAnnotationKey contains a property list object that the source application wanted to associate with the file when it was opened.
    If the UIApplicationLaunchOptionsURLKey key is present, your application must open the file referenced by that key and present its contents immediately. You can use the other keys in the dictionary to gather information about the circumstances surrounding the opening of the file.

保存共享的文件

请参考:

参考

  • 列有常见的配置信息

转载地址:https://windzen.blog.csdn.net/article/details/50847902 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:iOS简单手势解锁
下一篇:iOS事件响应链介绍

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月25日 03时07分45秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章