gpt4 book ai didi

ios - UIActivityViewController 未在我的应用程序中显示自定义文件类型的预期 AirDrop 选项

转载 作者:行者123 更新时间:2023-11-30 13:18:31 24 4
gpt4 key购买 nike

因此,通过 UIActivityViewController 共享文档的典型方式是类似于以下的代码:

let ac = UIActivityViewController(activityItems: [obj], applicationActivities: nil)
ac.popoverPresentationController?.sourceView = self.view
self.navigationController?.presentViewController(ac, animated: true, completion: nil)

问题是我不确定 obj 应该是什么样的类。我有一个可与 SolidWorks 的 eDrawings iOS 应用程序配合使用的文件。我知道它有效,因为我能够从我的笔记本电脑上通过 AirDrop 它,并且它被复制并在装有 eDrawings 应用程序的 iPad 上正确打开。

如果您查看包含所述 iPad 上 eDrawings 支持的文件类型的邮件消息,您可以看到它在弹出窗口中提供了预期的选项。

enter image description here

我的问题是,我怎样才能做同样的事情? Mail 必须在不明确知道 UTI 的情况下进行一般操作,因此我上面提供的示例代码中的 obj 字段应该是什么,以便让我的事件 View Controller 显示与 Mail 中相同的选项?我尝试过将 NSURL 与本地下载的文件以及网络上的 URL 一起使用。这些都不起作用。我认为我应该只使用 NSData,但那时,事件 View Controller 如何像 Mail 中那样隐式知道它是什么类型?

有什么想法吗?

最佳答案

尝试将“事件 View ”视为 iOS(无文件环境)中的一个位置,开发人员可以在其中允许其文件脱离设备。

API 说给我一个列表,我将填充 View 。文档包含隐藏在枚举描述中的详细信息...

用于 AirDrop

When using this service, you can provide NSString, NSAttributedString, UIImage, ALAsset, and NSURL objects as data for the activity items. You may also specify NSURL objects whose contents use the assets-library scheme. You may also provide NSArray or NSDictionary objects that contain the listed data types.

https://developer.apple.com/documentation/uikit/uiactivity/activitytype/1620665-airdrop

邮件

When using this service, you can provide NSString and UIImage objects and NSURL objects pointing to local files as data for the activity items. To specify an NSData object, you must implement the UIActivityItemSource protocol, return the data object in activityViewController(:itemForActivityType:), and return the data object’s UTI in activityViewController(:dataTypeIdentifierForActivityType:). Also, you may need to register the appropriate mapping so that the MIME type can be determined.

https://developer.apple.com/documentation/uikit/uiactivity/activitytype/1620669-mail

关于ios - UIActivityViewController 未在我的应用程序中显示自定义文件类型的预期 AirDrop 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38002864/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com