NSURL *url = [NSURL fileURLWithPath:file];
#if TARGET_OS_MACCATALYST
UIDocumentPickerViewController *browser = [[UIDocumentPickerViewController alloc] initWithURL:url inMode:UIDocumentPickerModeExportToService];
assert(browser);
browser.modalPresentationStyle = UIModalPresentationFormSheet;
browser.directoryURL = [NSURL fileURLWithPath:NSHomeDirectory()];
[self presentViewController:browser animated:YES completion:nil];
#else
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
assert(documentInteractionController);
documentInteractionController.delegate = self;
CGRect frame = [sender convertRect:CGRectMake(0, 0, sender.frame.size.width, sender.frame.size.height) toView:self.view];
[documentInteractionController presentOptionsMenuFromRect:frame inView:self.view animated:YES];
#endif
Commentaires