Skip to content

Commit

Permalink
Merge pull request #7 from helpscout/use-picker-for-ios11
Browse files Browse the repository at this point in the history
UIDocumentPickerViewController for iOS 11+
  • Loading branch information
samsymons authored Jun 18, 2018
2 parents 375dc49 + d5418c1 commit 295e5cd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions HSAttachmentPicker/HSAttachmentPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"]];
Expand Down

0 comments on commit 295e5cd

Please sign in to comment.