Search code examples
iosobjective-cuidocumentpickervc

How to allow only doc and pdf type in UIDocumentMenuViewController iOS?


I tried to load some files from Dropbox/G-Drive/iCloud using the UIDocumentMenuViewController. I tried,

UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(__bridge NSString*)kUTTypeContent] inMode:UIDocumentPickerModeImport];
importMenu.delegate = self;
importMenu.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:importMenu animated:YES completion:nil];

with this to get this done. But I need to get only the doc and pdf types only from picker. But when I use kUTTypeContent, this allows for images and videos also. Is there a way to allow this picker only for doc and pdf(custom types) or is there a why to prevent media files? Please help me with this.


Solution

  • I found a solution for this from apple developer site. There's a type called kUTTypeCompositeContent which is support only for all document types like doc, pdf, xls etc.

    public.composite-content:(kUTTypeCompositeContent)

    Base type for mixed content. For example, a PDF file contains both text and special formatting data.