4

I'm using UIDocumentPickerViewController for picking document. Below are the specified UTIs :

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

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

The files created from pages app (pages file) are grayed out and unable to pick. But WhatsApp document picker allowed to pick the same files. Am I missing any required UTI ?

My App :

enter image description here

WhatsApp:

enter image description here

UPDATE

com.apple.iwork.pages.sffpages did the trick for pages files on my device, but not working for the files on icloud drive. The complete code to present document picker is:

-(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];
}
iAkshay
  • 1,143
  • 1
  • 13
  • 35
  • As far as I understand you need all composite content formats and these are all of them kUTTypePDF, kUTTypeRTFD, kUTTypeFlatRTFD, kUTTypeTXNTextAndMultimediaData, kUTTypeWebArchive. – m1sh0 May 27 '19 at 08:20
  • @m1sh0 Thanks, but none of these are working :( – iAkshay May 27 '19 at 11:19
  • 1
    did you try with these once "com.apple.iwork.pages.pages", "com.apple.iwork.numbers.numbers", "com.apple.iwork.keynote.key" ??? – m1sh0 May 27 '19 at 12:01
  • @m1sh0 Yes, posted a question after tried that. – iAkshay May 27 '19 at 12:48
  • @m1sh0 I had to clean build after specifying these UTIs. Thanks for your time. – iAkshay Jun 04 '19 at 10:24

1 Answers1

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];

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

Florentin
  • 1,433
  • 2
  • 13
  • 22
  • com.apple.iwork.pages.sffpages did the trick, but now pages **on my device** only can access. When the same pages file copied the to **icloud drive**, its unaccessible. – iAkshay Jun 04 '19 at 07:03
  • However the numbers and keynote file on icloud drive are accessible, the pages not. – iAkshay Jun 04 '19 at 07:14
  • Please have a look at my update in the question. @TheFlow – iAkshay Jun 04 '19 at 09:13
  • @iAkki I updated my answer with an example code, could you try it? – Florentin Jun 04 '19 at 09:18
  • Fixed! I don't know why its always requiring me to clean project after changing the types. I forgot to clean last time when specified both .sffpages and .pages UTIs. Now its working. Many thanks for your help :) @TheFlow – iAkshay Jun 04 '19 at 10:03