iOS 应用中加载文档pdf/word/txt
一、加载PDF文档:应用内打开文档、手机中其他应用打开文档 Demo

首先拖入一个文档pdf、word、txt,打开不同的文档知识 文件名字、类型修改即可
#import "ReadViewController.h" @interface ReadViewController ()<UIDocumentInteractionControllerDelegate>
{
UIDocumentInteractionController * readvc;
}
@end @implementation ReadViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. [self creatButton]; } -(void)creatButton{ NSArray * arrtext = @[@"在其他App中打开",@"AppPreView"]; for (int i =; i<; i++) { UIButton * but = [UIButton buttonWithType:UIButtonTypeSystem];
but.frame = CGRectMake(, +i*, , );
but.tag = i;
[but setTitle:arrtext[i] forState:UIControlStateNormal]; [but addTarget:self action:@selector(but:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:but]; } } -(void)but:(UIButton*)but{ switch (but.tag) {
case :
{ NSURL * urll = [[NSBundle mainBundle]URLForResource:@"CocoaChina" withExtension:@"pdf"];
if (urll) {
readvc = [UIDocumentInteractionController interactionControllerWithURL:urll];
readvc.delegate = self;
[readvc presentOpenInMenuFromRect:[but frame] inView:self.view animated:YES]; } }
break;
case :{ //yulan
NSURL * urld =[[NSBundle mainBundle]URLForResource:@"CocoaChina" withExtension:@"pdf"]; if (urld) { readvc = [UIDocumentInteractionController interactionControllerWithURL:urld];
readvc.delegate = self;
[readvc presentPreviewAnimated:YES]; } }
default:
break;
} } -(UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller{ return self;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
iOS 应用中加载文档pdf/word/txt的更多相关文章
- 【Win 10 应用开发】在代码中加载文本资源
记得前一次,老周给大伙,不,小伙伴们介绍了如何填写 .resw 文件,并且在 XAML 中使用 x:Uid 标记来加载.也顺便给大伙儿分析了运行时是如何解析 .resw 文件的. 本来说好了,后续老周 ...
- iOS - 开发中加载本地word/pdf文档说明
最近项目中要加载一个本地的word/pdf等文件比如<用户隐私政策><用户注册说明>,有两种方法加载 > 用QLPreviewController控制器实现 步骤 : & ...
- 获取当前iframe动态加载文档的href
Insus.NET想实现一个功能,一个旧的站点A,它有两个网页logon.aspx和Default.aspx(登录成功能访问).由于某些原因,需另建一个新站点B,这个新站点B也有两个网页B_Index ...
- Jsoup解析HTML、加载文档等实例
一.引入jsoup的jar包:http://jsoup.org/download 补充:http://jsoup.org/apidocs/ Jsoup API 可以了解更详细的内容 二.Js ...
- ios开发中加载的image无法显示
昨天遇到一个较奇葩的问题,imageName加载的图片显示不出来,网上查了好多资料还是没找到解决的方法: 之前图片是放在项目中SupportingFiles文件下的,怎么加载都能显示图片,于是将图片拿 ...
- 2019-03-15 使用Request POST获取中加基金的PDF文件,并下载到本地
import requests import time base_url='http://www.bobbns.com/common-web/cms/content!getContentsInclud ...
- ios UIWebView 在开发中加载文件
UIWebView 在实际应用中加载文件的时候,有两种情况, 1. 实行在线预览 , 2. 下载到本地,再查看 如果是第一种情况: NSURL *url = [NSURL URLWithString: ...
- iOS开发中XML的DOM和SAX解析方法
一.介绍 dom是w3c指定的一套规范标准,核心是按树形结构处理数据,dom解析器读入xml文件并在内存中建立一个结构一模一样的“树”,这树各节点和xml各标记对应,通过操纵此“树”来处理xml中的文 ...
- 跟我extjs5(03--在项目过程中加载文件)
跟我extjs5(03--在项目过程中加载文件) 上一节中用sencha工具自己主动创建了一个项目.而且能够在浏览器中查看. 如今我们来看看js类载入过程. 例如以下图所看到的: watermark/ ...
随机推荐
- shell的逻辑运算符
一.逻辑运算符 逻辑卷标 表示意思 1. 关于档案与目录的侦测逻辑卷标! -f 常用!侦测『档案』是否存在 eg: if [ -f filename ] -d 常用!侦测『目录』是否存在 -b 侦测是 ...
- Linux下执行ls命令提示CMake Error错误
一.系统环境 Fedora10 二.出错情况 执行ls命令出现如下错误提示: CMake Error: The source directory "/etc/--color=auto&quo ...
- 2733:判断闰年-poj
2733:判断闰年 总时间限制: 1000ms 内存限制: 65536kB 描述 判断某年是否是闰年. 输入 输入只有一行,包含一个整数a(0 < a < 3000) 输出 一行,如果 ...
- SQL测试题
一.网上收集了一些测试题,对于掌握SQL查询语句. /* Navicat MySQL Data Transfer Source Server : lizebo's MYSQL Source Serve ...
- 数据库—Mysql
今天跟大家来聊聊Mysql,首先介绍一下它的历史: Mysql是一个关系型数据库管理系统,最先由瑞典的MySQL AB公司开发,后来被sun公司收购,后因sun公司又被Oracle公司收购,致使MyS ...
- cinder块存储控制节点
#cinder块存储控制节点 openstack pike 安装 目录汇总 http://www.cnblogs.com/elvi/p/7613861.html #cinder块存储控制节点 #在控制 ...
- Echarts后台封装option对象
该方法返回的keyword指向了前台负责图表显示的jsp页面 public String keyword() { if(this.dateNum == null || this.dateNum.equ ...
- oracle触发器 调用 web接口
最近要求开发当数据表发生变化的时候调用web接口的需求,上网找了好几篇文章看着都觉得不是很好,也根据别人的思路去实现了下,感觉都不太理想,最后使用URLConnection实现了调用.具体查看一下代码 ...
- linux nginx搭配https
微信小程序upload接口必须是https请求,所以就搭建https 1.申请ssl证书 这里用的是腾讯云提供的免费ssl. https://console.qcloud.com/ssl?_ga=1. ...
- 32位linux(centos)下mongoDB的安装
下载mongoDB wget http://downloads.mongodb.org/linux/mongodb-linux-i686-2.4.9.tgz 如果上面地址不对可以去官网自己下载http ...