How to initialise UIDocumentPickerViewController with all type of UTIs

拥有回忆 提交于 2019-12-03 09:05:01

问题


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

回答1:


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




回答2:


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



回答3:


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

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




回答4:


Swift 5:

import MobileCoreServices

    let importMenu = UIDocumentPickerViewController(documentTypes: ["public.item"], in: .import)
    importMenu.delegate = self
    importMenu.modalPresentationStyle = .fullScreen
    self.present(importMenu, animated: true, completion: nil)


来源:https://stackoverflow.com/questions/33099775/how-to-initialise-uidocumentpickerviewcontroller-with-all-type-of-utis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!