How to initialise UIDocumentPickerViewController with all type of UTIs

前端 未结 4 1931
星月不相逢
星月不相逢 2021-02-04 06:39

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 sti

相关标签:
4条回答
  • 2021-02-04 06:56

    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)
    
    0 讨论(0)
  • 2021-02-04 06:58

    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

    0 讨论(0)
  • 2021-02-04 07:00
    UIDocumentPickerViewController* documentPicker = 
      [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.item"]
                                                             inMode:UIDocumentPickerModeImport];
    
    0 讨论(0)
  • 2021-02-04 07:01

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

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

    0 讨论(0)
提交回复
热议问题