Anand Kore
Anand Kore

Reputation: 1330

Not able to select multiple files using UIDocumentPickerViewController

I'm trying to import/pick multiple files at once from files app using UIDocumentPickerViewController.

Tried setting allowsMultipleSelection = true but still there is no "Select" option while picker is presented.

Code snippet :

UIDocumentPickerViewController *dvc = [[UIDocumentPickerViewController alloc]initWithDocumentTypes:arrContents inMode:UIDocumentPickerModeImport];
dvc.delegate = self;
dvc.allowsMultipleSelection = true;
[self presentViewController:dvc animated:true completion:nil];

Screenshot : enter image description here

Upvotes: 16

Views: 6631

Answers (1)

WetFish
WetFish

Reputation: 1212

This is a bug Apple needs to fix. You can use this workaround. If you set animated: to YES, it will only work the first time you show the document picker.

Objective-C:

[self presentViewController:dvc animated:NO completion:^{
    if (@available(iOS 11.0, *)) {
        dvc.allowsMultipleSelection = YES;
    }
}];

Swift 4:

self.present(dvc, animated: false) {
    if #available(iOS 11.0, *) {
        dvc.allowsMultipleSelection = true;
    }
}

Upvotes: 14

Related Questions