Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 649
Anand Kore Avatar asked Nov 01 '17 10:11

Anand Kore


Video Answer


1 Answers

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;
    }
}
like image 68
WetFish Avatar answered Oct 22 '22 19:10

WetFish