How to initialise UIDocumentPickerViewController w

2019-03-13 13:29发布

I want to open UIDocumentPickerViewController and It should allow user to select all type of files. I tried to mention all UTIs in UIDocumentPickerViewController init method still couldnt find valid UTIs for some of files like rar,Visio files,mpp,mpt

UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:[MingleUtils allowedUTIs] inMode:UIDocumentPickerModeImport];

and

+(NSArray*)allowedUTIs{
    return @[@"public.data",@"public.content",@"public.audiovisual-content",@"public.movie",@"public.audiovisual-content",@"public.video",@"public.audio",@"public.text",@"public.data",@"public.zip-archive",@"com.pkware.zip-archive",@"public.composite-content",@"public.text"];
}

3条回答
Lonely孤独者°
2楼-- · 2019-03-13 13:52

If you want to allow any file type, you should use

UIDocumentPickerViewController* documentPicker = 
  [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"]
                                                         inMode:UIDocumentPickerModeImport];

See apple docs for UTI concepts

查看更多
疯言疯语
3楼-- · 2019-03-13 13:55
UIDocumentPickerViewController* documentPicker = 
  [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.item"]
                                                         inMode:UIDocumentPickerModeImport];
查看更多
ゆ 、 Hurt°
4楼-- · 2019-03-13 14:07

I think your best shot is to use abstract UTI types.

Using kUTTypeContent and kUTTypeItem should cover most of the file types.

查看更多
登录 后发表回答