Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIDocumentPickerViewController iOS13 not Working

On my application, i use UIDocumentPickerViewController to allow the user to pick files (import), but starting from iOS 13 that functionality stop working, basically the document picker is open, but the user can't choose a file (taping the file does nothing).

I made a simple sample just to isolate the code:

class ViewController: UIViewController, UIDocumentPickerDelegate {

    @IBAction func openDocumentPicker(_ sender: Any) {
        let types = [String(kUTTypePDF)]
        let documentPickerViewController = UIDocumentPickerViewController(documentTypes: types, in: .import)
        documentPickerViewController.delegate = self
        present(documentPickerViewController, animated: true, completion: nil)
    }

    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
        print("Cancelled")
    }

    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        print("didPickDocuments at \(urls)")
    }

}

Sample project: https://github.com/Abreu0101/document-picker-iOS13-issue

Reference: enter image description here

like image 865
José Roberto Abreu Avatar asked Sep 10 '19 01:09

José Roberto Abreu


2 Answers

When I got this issue, I realised that it's working when choosing files from "Browse" tab because I implemented the method "didPickDocumentAt", but it was not working when I tapped on files from "Recent" tab.

To make it work on "Recent" tab, I'd to implement the method "didPickDocumentsAt", which makes the same thing, but it handles an array of URLs.

like image 127
Allan Avatar answered Nov 20 '22 13:11

Allan


On Mojave there's the problem, make sure you upgrade your os to Catalina.

  • https://github.com/Elyx0/react-native-document-picker/issues/246
  • UIDocumentBrowserViewController error "Cannot create urlWrapper for url" on iOS13 simulator
like image 39
saad agoujil Avatar answered Nov 20 '22 12:11

saad agoujil