一、加载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的更多相关文章

  1. 【Win 10 应用开发】在代码中加载文本资源

    记得前一次,老周给大伙,不,小伙伴们介绍了如何填写 .resw 文件,并且在 XAML 中使用 x:Uid 标记来加载.也顺便给大伙儿分析了运行时是如何解析 .resw 文件的. 本来说好了,后续老周 ...

  2. iOS - 开发中加载本地word/pdf文档说明

    最近项目中要加载一个本地的word/pdf等文件比如<用户隐私政策><用户注册说明>,有两种方法加载 > 用QLPreviewController控制器实现 步骤 : & ...

  3. 获取当前iframe动态加载文档的href

    Insus.NET想实现一个功能,一个旧的站点A,它有两个网页logon.aspx和Default.aspx(登录成功能访问).由于某些原因,需另建一个新站点B,这个新站点B也有两个网页B_Index ...

  4. Jsoup解析HTML、加载文档等实例

    一.引入jsoup的jar包:http://jsoup.org/download 补充:http://jsoup.org/apidocs/   Jsoup API    可以了解更详细的内容 二.Js ...

  5. ios开发中加载的image无法显示

    昨天遇到一个较奇葩的问题,imageName加载的图片显示不出来,网上查了好多资料还是没找到解决的方法: 之前图片是放在项目中SupportingFiles文件下的,怎么加载都能显示图片,于是将图片拿 ...

  6. 2019-03-15 使用Request POST获取中加基金的PDF文件,并下载到本地

    import requests import time base_url='http://www.bobbns.com/common-web/cms/content!getContentsInclud ...

  7. ios UIWebView 在开发中加载文件

    UIWebView 在实际应用中加载文件的时候,有两种情况, 1. 实行在线预览 , 2. 下载到本地,再查看 如果是第一种情况: NSURL *url = [NSURL URLWithString: ...

  8. iOS开发中XML的DOM和SAX解析方法

    一.介绍 dom是w3c指定的一套规范标准,核心是按树形结构处理数据,dom解析器读入xml文件并在内存中建立一个结构一模一样的“树”,这树各节点和xml各标记对应,通过操纵此“树”来处理xml中的文 ...

  9. 跟我extjs5(03--在项目过程中加载文件)

    跟我extjs5(03--在项目过程中加载文件) 上一节中用sencha工具自己主动创建了一个项目.而且能够在浏览器中查看. 如今我们来看看js类载入过程. 例如以下图所看到的: watermark/ ...

随机推荐

  1. Iterator & Iterable 和 Comparable&Comparator

    java.lang.Iterator & java.lang.Iterable Iterator和Iterable的区别和联系 iterator是具有迭代状态的对象.它允许你检查它是否有更多的 ...

  2. 软件测试博客日记Day02-11.16日 —— 赵天宇 —— 禅道的使用和配置

    禅道 1. 安装 1. 进入禅道的官方下载地址:http://www.zentao.net/download/80053.html 2. 下载禅道开源版本. 3. 正常安装,注意一定要放在根目录下. ...

  3. Minecraft

    描述 Minecraft是一个几乎无所不能的沙盒游戏,玩家可以利用游戏内的各种资源进行创造,搭建自己的世界. 在Minecraft中,基本的建筑元素是边长为1个单位的立方体,Tony想用N个这种小立方 ...

  4. git学习之创建版本库

    创建版本库 什么是版本库呢?版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改.删除,Git都能跟踪,以便任何时刻都可以 ...

  5. npoi导入导出

    NPOI是指构建在POI 3.x版本之上的一个程序,NPOI可以在没有安装Office的情况下对Word或Excel文档进行读写操作. NPOI是一个开源的Java读写Excel.WORD等微软OLE ...

  6. 《java.util.concurrent 包源码阅读》06 ArrayBlockingQueue

    对于BlockingQueue的具体实现,主要关注的有两点:线程安全的实现和阻塞操作的实现.所以分析ArrayBlockingQueue也是基于这两点. 对于线程安全来说,所有的添加元素的方法和拿走元 ...

  7. 异常:Unknown lifecycle phase "mvn". You must specify a valid lifecycle

    这是在使用maven打包方式启动springboot项目时出现的异常, 我的异常原因属于下面的情况: 此时maven指令行为:mvn spring-boot:run. 如果写成这样会导致最终的mave ...

  8. listview优化加强版

    import android.content.Context;import android.graphics.Bitmap;import android.graphics.BitmapFactory; ...

  9. daemon 启动system V init 和 systemd 配置

    先试着写一个udpserver的daemon #include <stdio.h> #include <sys/socket.h> #include <sys/types ...

  10. Swarm 如何存储数据?- 每天5分钟玩转 Docker 容器技术(103)

    service 的容器副本会 scale up/down,会 failover,会在不同的主机上创建和销毁,这就引出一个问题,如果 service 有要管理的数据,那么这些数据应该如何存放呢? 选项一 ...