From d5418c12f11597010f250b2f4b93b77d31970672 Mon Sep 17 00:00:00 2001 From: Jason Gritman Date: Mon, 18 Jun 2018 15:08:01 -0600 Subject: [PATCH] UIDocumentMenuController was deprecated in iOS 11, using UIDocumentPicerViewController if it's available --- HSAttachmentPicker/HSAttachmentPicker.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/HSAttachmentPicker/HSAttachmentPicker.m b/HSAttachmentPicker/HSAttachmentPicker.m index deac0cf..ce286c4 100644 --- a/HSAttachmentPicker/HSAttachmentPicker.m +++ b/HSAttachmentPicker/HSAttachmentPicker.m @@ -62,9 +62,15 @@ -(void)showAttachmentMenu { -(void)showDocumentPicker { @try { NSArray *documentTypes = [[NSArray alloc] initWithObjects:(NSString*)kUTTypeItem, nil]; - UIDocumentMenuViewController *documentMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeImport]; - documentMenu.delegate = self; - [self.delegate attachmentPickerMenu:self showController:documentMenu completion:nil]; + if (@available(iOS 11.0, *)) { + UIDocumentPickerViewController *documentMenu = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeImport]; + documentMenu.delegate = self; + [self.delegate attachmentPickerMenu:self showController:documentMenu completion:nil]; + } else { + UIDocumentMenuViewController *documentMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeImport]; + documentMenu.delegate = self; + [self.delegate attachmentPickerMenu:self showController:documentMenu completion:nil]; + } } @catch (NSException *exception) { [self showError:[self translateString:@"This application is not entitled to access iCloud"]];