Commit 3146a3b6 authored by Pavel Akhrameev's avatar Pavel Akhrameev Committed by Carola Nitz

Multiple file selection from iCloud drive

parent 6b74f739
......@@ -22,13 +22,31 @@
#pragma mark - Internal Methods
- (void)showDocumentMenuViewController:(id)sender
{
- (UIViewController *) configurePickerViewController {
NSArray *types = @[(id)kUTTypeAudiovisualContent];
UIDocumentPickerMode mode = UIDocumentPickerModeImport;
if (@available(iOS 11.2, *)) {
// UIDocumentMenuViewController deprecated and does not support multiple selection
UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes: types inMode:mode];
picker.delegate = self;
picker.allowsMultipleSelection = YES;
return picker;
} else {
UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(id)kUTTypeAudiovisualContent] inMode:UIDocumentPickerModeImport];
importMenu.delegate = self;
return importMenu;
}
}
- (void)showDocumentMenuViewController:(id)sender
{
UIViewController *picker = [self configurePickerViewController];
UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIPopoverPresentationController *popoverPres = importMenu.popoverPresentationController;
UIPopoverPresentationController *popoverPres = picker.popoverPresentationController;
if (popoverPres) { // not-nil on iPad
UIView *sourceView = nil;
......@@ -43,7 +61,7 @@
popoverPres.permittedArrowDirections = UIPopoverArrowDirectionLeft;
}
[rootVC presentViewController:importMenu animated:YES completion:nil];
[rootVC presentViewController:picker animated:YES completion:nil];
}
#pragma mark - UIDocumentMenuDelegate
......@@ -57,6 +75,13 @@
#pragma mark - UIDocumentPickerDelegate
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray <NSURL *>*)urls NS_AVAILABLE_IOS(11_0);
{
for (NSURL *url in urls) {
[self documentPicker:controller didPickDocumentAtURL:url];
}
}
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
{
NSFileManager *fileManager = [NSFileManager defaultManager];
......@@ -76,7 +101,6 @@
[alert addAction:okAction];
[rootVC presentViewController:alert animated:true completion:nil];
}
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment