标签:文档
#pragma mark Actions - (IBAction)previewDocument:(id)sender { NSURL *URL = [[NSBundle mainBundle] URLForResource:@"sample" withExtension:@"pdf"]; if (URL) { // Initialize Document Interaction Controller self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL]; // Configure Document Interaction Controller [self.documentInteractionController setDelegate:self]; // Preview PDF [self.documentInteractionController presentPreviewAnimated:YES]; } } - (IBAction)openDocument:(id)sender { UIButton *button = (UIButton *)sender; NSURL *URL = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"pdf"]; if (URL) { // Initialize Document Interaction Controller self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL]; // Configure Document Interaction Controller [self.documentInteractionController setDelegate:self]; // Present Open In Menu [self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES]; } } #pragma mark - #pragma mark Document Interaction Controller Delegate Methods - (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller { return self; }
标签:文档
原文地址:http://8287272.blog.51cto.com/8277272/1659558