How can I import multiple files at the same time using UIDocumentPickerViewController?

Can UIDocumentPickerViewController be used to allow the user to select multiple files to import from another application?

+3


source to share


2 answers


Use the following code snippet, this will add a Select button next to the header to select multiple files at once and import them.

UIDocumentPickerViewController *dvc = [[UIDocumentPickerViewController alloc]initWithDocumentTypes:arrContents inMode:UIDocumentPickerModeImport];
        dvc.delegate = self;
        [self presentViewController:dvc animated:true completion:^{
            if (@available(iOS 11.0, *)) {
                    dvc.allowsMultipleSelection = true;
            }
        }];

      

and



- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray <NSURL *>*)urls

to get a list of the selected files.

+1


source


The UIDocumentPickerViewController delegator can only return one file, not all:

- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url

      



So unfortunately this is not possible :(

-1


source







All Articles