美文网首页
iOS SDK:预览和打开文档

iOS SDK:预览和打开文档

作者: 风继续吹0 | 来源:发表于2016-08-19 17:13 被阅读50次
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake((CGRectGetWidth(self.view.frame)-80)/2, 200, 80, 40)];
btn.backgroundColor = [UIColor cyanColor];
[btn setTitle:@"浏览" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(previewDocument) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
- (void)previewDocument{
NSURL *URL = [[NSBundle mainBundle] URLForResource:@"iOS SDK:预览和打开文档" withExtension:@"pdf"];
if (URL) {
    // Initialize Document Interaction Controller
    UIDocumentInteractionController *documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
    // Configure Document Interaction Controller
    [documentInteractionController setDelegate:self];
    // Preview PDF
    [documentInteractionController presentPreviewAnimated:YES];
    }
}
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *) controller {
return self;
}
效果图

相关文章

  • iOS SDK:预览和打开文档

  • iOS QLPreviewController 文件预览

    iOS QLPreviewController 文件预览 官方SDK提供了一个QLPreviewControlle...

  • QLPreviewController使用方法

    在iOS SDK包括了QLPreviewControllerAPI在[iOS]中用于方便预览文件,它支持的文件有:...

  • QLPreviewController的使用

    在iOS SDK包括了QLPreviewControllerAPI在[iOS]中用于方便预览文件,它支持的文件有:...

  • iOS源码博文集锦5

    iOS精选源码 自己维护的框架, 超级多功能 图片选择SDK:支持多选,相册选择,预览,网络图预览 一款可以简单实...

  • UIWebView使用浅析

    概述 UIWebView是iOS sdk中一个最常用的控件,是内置的浏览器控件,我们可以用它来浏览网页、打开文档等...

  • 极光推送 iOS 官方文档快速入口

    极光推送官网iOS SDK 概述iOS SDK 教程iOS SDK APIiOS SDK 集成指南iOS SDK ...

  • 脑暴

    基于markdown语法的IOS/Android排版引擎 包括移动端sdk,还有配套的web端写作和预览系统mar...

  • WebView的使用

    UIWebView是iOS sdk中一个最常用的控件。是内置的浏览器控件,我们可以用它来浏览网页、打开文档等等,U...

  • iOS端 MuPDF集成使用总结

    由于之前需求用的是福昕SDK做的PDF预览与批注,也特别感谢大神的帮助iOS PDF文档批注与修改,由于福昕SDK...

网友评论

      本文标题:iOS SDK:预览和打开文档

      本文链接:https://www.haomeiwen.com/subject/hdbbsttx.html