无法使用UIDocumentPickerViewController选择页面文件

时间:2019-05-27 07:41:23

标签: ios objective-c file uidocumentpickerviewcontroller

我正在使用UIDocumentPickerViewController来选择文档。以下是指定的UTI:

NSArray *types = @[(NSString*)kUTTypeImage,(NSString*)kUTTypeSpreadsheet,(NSString*)kUTTypePresentation,(NSString*)kUTTypePDF,(NSString*)kUTTypeRTF,(NSString*)kUTTypePlainText,(NSString*)kUTTypeText];

UIDocumentPickerViewController *dpvc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:types inMode:UIDocumentPickerModeImport];

但是从页面应用程序创建的文件(页面文件)显示为灰色,无法选择。我是否缺少任何必需的UTI?

enter image description here

1 个答案:

答案 0 :(得分:4)

实际上,Pages文件有2种不同的类型,可以是捆绑文件,也可以是单个文件,我认为您希望应用程序同时处理这两种文件。

对应的UTI是com.apple.iwork.pages.sffpagescom.apple.iwork.pages.pages

导入iWork文件的代码示例:

NSArray *types = @[@"com.apple.iwork.pages.sffpages", @"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"];

UIDocumentPickerViewController *dpvc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:types inMode:UIDocumentPickerModeImport];

如果您仍然对UIDocumentPickerViewControllerhttps://developer.apple.com/videos/play/wwdc2018/216

有疑问,我还建议您观看此WWDC会话