15

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

Parth Patel
  • 915
  • 11
  • 33
Anand Kore
  • 1,300
  • 1
  • 15
  • 33

1 Answers1

13

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;
    }
}
WetFish
  • 1,172
  • 2
  • 11
  • 21
  • 2
    Sometimes you need to switch between "Recents" and "Browse" before the "Select" button becomes visible on iPad. If you present the document picker as form sheet, it should be visible right away. – WetFish Nov 30 '17 at 18:52
  • 2
    But this really needs to be fixed by Apple. I already filed a radar. You should, too! – WetFish Nov 30 '17 at 18:53
  • Make sure to use `documentPicker:didPickDocumentsAtURLs:` instead of `documentPicker:didPickDocumentAtURL:`. – Chintan Shah Jan 11 '19 at 06:00
  • 2
    How is this still not fixed on iOS 14!? Also, the answer doesn't seem to work on iOS 14... – Sweeper Oct 24 '20 at 04:12
  • 3
    Turns out it's a behaviour change. Please refer to the "iOS" section, here: https://github.com/DelphiWorlds/Kastri/blob/master/Demos/FilesSelector/ReadMe.md – Dave Nottage Feb 25 '21 at 23:02