0

I am trying to select multiple files in document picker. Here is my code:

let documentPicker = UIDocumentPickerViewController(documentTypes: [String(kUTTypeFolder)], in: .import)
documentPicker.delegate = self
self.present(documentPicker, animated: false) {
    if #available(iOS 11.0, *) {
        documentPicker.allowsMultipleSelection = true
    }
}

But it is selecting only 1 file at a time. Can anyone suggest me a correct way?

Any help would be highly appreciated!!

Andrei Konstantinov
  • 6,971
  • 4
  • 41
  • 57
User511
  • 1,456
  • 10
  • 28

1 Answers1

4

Just do it before

self.present

your code should be

 let documentPicker = UIDocumentPickerViewController(documentTypes: [String(kUTTypeFolder)], in: .import)
        documentPicker.delegate = self
        if #available(iOS 11.0, *) {
             documentPicker.allowsMultipleSelection = true
         }
        self.present(documentPicker, animated: false) {

        }

and check in Browse tab, not in Recenets tab

m1sh0
  • 2,236
  • 1
  • 16
  • 21
  • it goes to the folder only and also picker is not dismissed on clicking done button. – User511 Jun 03 '19 at 07:09
  • yep, you need to click open after you finish with selection. The done button just finish the selection. – m1sh0 Jun 03 '19 at 16:48