User511
User511

Reputation: 1486

Multiple selection for document picker controller

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!!

Upvotes: 0

Views: 3981

Answers (1)

m1sh0
m1sh0

Reputation: 2351

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

Upvotes: 4

Related Questions