无法使用UIDocumentPickerViewController选择页面文件

iAk*_*kki 4 file objective-c ios 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];
Run Code Online (Sandbox Code Playgroud)

从页面应用创建的文件(页面文件)显示为灰色,无法选择。但是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];
}
Run Code Online (Sandbox Code Playgroud)

The*_*ow_ 5

Actually, there are 2 different types for Pages files, it could be a bundle or a single file, and I think that you want your app to handle both.

The corresponding UTIs are com.apple.iwork.pages.sffpages and com.apple.iwork.pages.pages.

Example of code to import iWork files:

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];
Run Code Online (Sandbox Code Playgroud)

I also recommand that you watch this WWDC session if you still have trouble with UIDocumentPickerViewController: https://developer.apple.com/videos/play/wwdc2018/216