一、加载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. 通过hadoop + hive搭建离线式的分析系统之快速搭建一览

    最近有个需求,需要整合所有店铺的数据做一个离线式分析系统,曾经都是按照店铺分库分表来给各自商家通过highchart多维度展示自家的店铺经营 数据,我们知道这是一个以店铺为维度的切分数据,非常适合目前 ...

  2. 一个在java后台实现的对图片进行加网纹或水印的工具类

    import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Graphic ...

  3. lua table操作实例详解

    lua_gettable lua_getglobal(L, "mytable") <== push mytable lua_pushnumber(L, 1)        & ...

  4. null与undefined的比较

    null在JavaScript中是关键字,它属于一个特殊的值,即空值. 而undefined它不是关键字,它表示未定义,属于预定义的全局变量. null == undefined 返回的是 true  ...

  5. [C#]使用Gembox.SpreadSheet向Excel写入数据及图表

    本文为原创文章.源代码为原创代码,如转载/复制,请在网页/代码处明显位置标明原文名称.作者及网址,谢谢! 开发工具:VS2017 语言:C# DotNet版本:.Net FrameWork 4.0及以 ...

  6. Azure IoT Edge on Raspberry Pi 3 with Raspbian

    在<Azure IoT Edge on Windows 10 IoT Core>一文中,我们以运行Windows 10 IoT Core的MinnowBoard MAX为例,详细讲述了Wi ...

  7. codeforces 893A Chess For Three 模拟

    893A Chess For Three 思路: 直接模拟即可,第一盘永远是A与B开始 代码: #include <bits/stdc++.h> using namespace std; ...

  8. MongoDb安装--yum安装

    本帖最后由 草包 于 2017-5-2 09:57 编辑 [Shell] 纯文本查看 复制代码 ? 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 ...

  9. cookie大小

    一.浏览器允许每个域名所包含的cookie数: Microsoft指出InternetExplorer8增加cookie限制为每个域名50个,但IE7似乎也允许每个域名50个cookie. Firef ...

  10. Linux 编程--三种常用的定时器

    这节我们来探讨一下linux开发过程中常用的定时器,尤其在网络编程中被常常用到如heartbeat,断线重连等等.这里提供了三种定时器的方案,分别是链表形式的计时器,环型计时器,最小堆计时器.每个都有 ...