无法使用 UIDocumentPickerViewController 选择页面文件

Unable to pick pages file with 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];

从pages app创建的文件(pages file)是灰色的,无法拾取。但是 WhatsApp 文档选择器允许选择相同的文件。我是否缺少任何必需的 UTI?

我的应用程序:

WhatsApp:

更新

com.apple.iwork.pages.sffpages 对我设备上的页面文件有效,但对 icloud 驱动器上的文件不起作用。呈现文档选择器的完整代码是:

-(IBAction)showDocumentPicker:(id)sender
{
    NSArray *types = @[(NSString*)kUTTypeImage,(NSString*)kUTTypeSpreadsheet,(NSString*)kUTTypePresentation,(NSString*)kUTTypePDF,(NSString*)kUTTypeRTF,(NSString*)kUTTypePlainText,(NSString*)kUTTypeText, @"com.apple.iwork.pages.sffpages"];

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

    dpvc.delegate = self;

    //colorFromHex 4285f4
    [[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:66.0/255.0 green:133.0/255.0 blue:244.0/255.0 alpha:1.0]];

    [self presentViewController:dpvc animated:YES completion:nil];
}

实际上,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];

如果您仍然无法使用 UIDocumentPickerViewController,我还建议您观看此 WWDC session:https://developer.apple.com/videos/play/wwdc2018/216