gpt4 book ai didi

ios - 具有自定义 UTI 的 iCloud 文档选取器

转载 作者:行者123 更新时间:2023-12-02 03:09:25 24 4
gpt4 key购买 nike

UIDocumentPickerViewController initWithDocumentTypes 是否需要公共(public) UTI 才能运行?

我正在尝试利用 iCloud 文档来允许用户从 iCloud Drive 导入专有文件类型。测试对于公共(public) UTI 效果很好,例如:@"public.text"

如果我不在 initWithDocumentTypes 数组中包含公共(public) UTI,我会看到一个屏幕,指示:

No Documents. Documents in iCloud Drive are not available because the iCloud Documents & Data setting is disabled.

我导入的 UTI 在“目标”>“信息”中定义为“com.domain.file”。我必须相信这是正确设置的,因为我可以在另一个应用程序(例如 Dropbox)中选择我的专有文件之一,并且我的应用程序显示在“打开方式...”选项中。

在我的导入操作中,我尝试了所有我能想到的变体,让我的自定义 UTI 显示选择器。

- (IBAction)importDocumentPickerTapped:(id)sender
{
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc initWithDocumentTypes:@[@"com.domain.file", @"com.domain.app.file", @"iCloud.com.domain.file", @"iCloud.com.domain.app.file" ] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
}

如果我将 @"public.text" 添加到 initWithDocumentTypes 数组中,则 iCloud 云端硬盘位置选择器屏幕将按预期显示。我可以选择 .txt 和 .rtf 文件,但我的自定义文件类型呈灰色且无法选择。

注意:

  1. 我尚未创建文档提供程序扩展,因为我认为这不是必需的,而且我的文件格式并不常见。
  2. 当我对 UIDocumentPickerViewController 执行任何操作时,即使是“取消”并且对文件(即保存 .txt)的操作有效,我也会看到以下警告。我花了相当多的时间试图找出这个警告的来源,但没有成功。

plugin com.apple.UIKit.fileprovider.default invalidated

最佳答案

我遇到了这个问题,并通过让我的自定义导出的 UTI 符合“public.data”UTI 来解决它。

您可以通过选择目标然后选择信息选项卡来进行设置。滚动到导出的 UTI 部分并将其展开。在您的自定义 UTI 下有一个框来声明它符合要求。

请参阅此处了解系统定义的 UTI 列表: https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html

关于ios - 具有自定义 UTI 的 iCloud 文档选取器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30079165/

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