這個範例示範彈出 Open In 的選項,來開啟外部 App.
sample:
https://www.ioscreator.com/tutorials/open-pdf-documents-in-ios
add <UIDocumentInteractionControllerDelegate>:
@interface ViewController : UIViewController <UIDocumentInteractionControllerDelegate>
Add a UIDocumentInteractionController property:
@property (nonatomic, strong) UIDocumentInteractionController *controller;
implement the openPDF IBAction method:
- (IBAction)openPDF:(id)sender { NSURL *URL = [[NSBundle mainBundle] URLForResource:@"MobileHIG" withExtension:@"pdf"]; if (URL) { self.controller = [UIDocumentInteractionController interactionControllerWithURL:URL]; self.controller.delegate = self; // Present "Open In Menu" [self.controller presentOpenInMenuFromRect:[sender frame] inView:self.view animated:YES]; } }
Done…