#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; }
打开文档的使用方法
原创
©著作权归作者所有:来自51CTO博客作者jackscm的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:iosWebView加载本地js
下一篇:利用手势控制动画的进度
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Android WPS SDK 打开文档功能初体验
android WPS sdk 打开文档 word 文字 ppt 演示 pdf excel表格 开发 体验
android WPS 文档 打开 sdk