iOS 文件预览 UIDocumentInteractionController

Ios UIDocumentInteractionController (预览类似pdf、doc、ppt等类型文件的类) UIDocumentInteractionController是OC语言的一个类,但是他并不是一个controller,而是一个继承自NSObject类 一、主要作用: 预览类似pdf、doc、ppt等类型文件的类。 可以将用户接收到的文件分享到用户手机上的其他App中。 二、使用方式: 1.预览文件,并可以分享文件,如图1 2.直接分享文件,如图2 三、使用方法: 1.创建一个UIDoc... 阅读详情

在应用开发中,有时候需要预览文档和视频,使用 UIDocumentInteractionController 来预览文件非常方便,支持的格式比较多,比如 docx、xlsx、pdf、mov、mp4、jpg、png 等等都可以。具体代码如下:

@interface ViewController () <UIDocumentInteractionControllerDelegate>
 
@property(nonatomic,strong) UIDocumentInteractionController * documentVC;
 
@end
 
@implementation ViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"第 7 章 Mach-O 文件格式解析" ofType:@"docx"];
    NSURL *url = [NSURL fileURLWithPath:path];
    
    self.documentVC = [UIDocumentInteractionController interactionControllerWithURL:url];
    self.documentVC.delegate = self;
    
    dispatch_async(dispatch_get_main_queue(), ^{
        BOOL b = [self.documentVC presentPreviewAnimated:YES];
    });
}
 
#pragma mark 代理方法
//为快速预览指定控制器
- (UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController*)controller
{
    NSLog(@"%@",NSStringFromSelector(_cmd));
    return self;
}
 
//为快速预览指定View
- (UIView*)documentInteractionControllerViewForPreview:(UIDocumentInteractionController*)controller
{
    NSLog(@"%@",NSStringFromSelector(_cmd));
    return self.view;
}
 
//为快速预览指定显示范围
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController*)controller
{
    NSLog(@"%@",NSStringFromSelector(_cmd));
    //    return self.view.frame;
    return CGRectMake(0, 0, self.view.frame.size.width, 300);
}
 
@end

 

效果如下图,点击 Done 就能回到主界面。

原文地址:https://www.exchen.net/ios-%E6%96%87%E4%BB%B6%E9%A2%84%E8%A7%88-uidocumentinteractioncontroller.html

iOS 关于下载word/png/excel附件并打开预览 需求:下载过的文件列表显示已下载,可以直接点击预览,如果没下载就提示它去下载 首先下载文件并预览这一过程,需要由下载文件路径,存储路径,预览文件三个步骤来完成。 不多说,直接上代码: #pragma makr-----点击下载 - (void)noticeActionWithUrlStr:(NSString *)url model:(GQNFileModel *)model ... 阅读详情

相关推荐

iOS利用UIDocumentInteractionController和Quick Look打开或预览文档

在App的开发过程中,我们避免不了要打开软件中的文件,例如:Excel文件,Word文件,图片文件等不同格式的文件或者想要通过第三方的App来打开这些文件,那么我们就要用到UIDocumentInteractionController和Quick Look来解决这些问题了。 UIDocumentInteractionController的使用方法 UIDocumentInterRactio

backAFENG的专栏 3073

(0090)iOS开发之本地文件预览的三种方法(1)

UIDocumentInteractionController

沐雨07的专栏 1353

iOS 预览 UIDocumentInteractionController QLPreviewController

本demo使用两种预览方式:UIDocumentInteractionController QLPreviewController 展示文件

iOS开发之UIDocumentInteractionController

本文介绍如何利用UIDocumentInteractionController和QuickLook通过第三方的App来快速打开一些文件

shxwork的博客 5216

Python主要智能优化算法库汇总

最近几年简单浏览和对比了一些智能算法的库。现将各种库的主要信息、相关优缺点简单整理如下,各位同学可根据自己的需求和喜好进行选择。 文章目录1、DEAP2、mealpy3、scikit-opt (国产良心)4、Geat2(国产用心)5、pygmo26、pyswarms7、SciPy(想不到吧)小结 1、DEAP 项目地址:https://github.com/DEAP/deap 安装: pip install deap 优点: 起点高,发表在Journal of Machine Learning Rese

半个冯博士 2万+

【农业生产系统模型】基于R语言APSIM模型进阶应用与参数优化、批量模拟实践技术

APSIM模型有Classic和Next Generation两个系列模型,能模拟几十种农作物、牧草和树木的土壤-植物-大气过程,被广泛应用于精细农业、水肥管理、气候变化、粮食安全、土壤碳周转、环境影响、农业可持续性、农业生态等诸多与农业生产和科研有关的领域。R语言是一门应用场景广泛、简单易学的程序语言,APSIM模型开发了许多R语言辅助包,在APSIM模型的气候、土壤、管理措施等数据准备,自动化模拟,参数优化和结果分析上都发挥着重要的作用。案例一:APSIM模型输入参数和土壤文件的制备。

2303_79243743的博客 1049

iOS开发-QLPreviewController与UIDocumentInteractionController显示文档

iOS开发-QLPreviewController与UIDocumentInteractionController显示文档在应用中,我们有时想预览文件, 可以使用QLPreviewController与UIDocumentInteractionController。

一名开发者 1960

010Editor实战:5分钟破解Zip伪加密文件(附BUUCTF真题解析)

本文详细介绍了如何使用010Editor快速破解Zip伪加密文件,包括BUUCTF真题的完整解析。通过修改关键字节,轻松解除伪加密状态,适用于CTF竞赛和实际工作场景,提升文件处理效率。

weixin_29325007的博客 337

ios开发之--UIDocumentInteractionController的使用(实现更多分享服务)

最近在做项目的时候,碰到这样一个需求,就是本地生成pdf文件,然后本地打开,经过测试发现,pdf文件是无法保存到相册里面的,只能存到手机里面,鉴于苹果的存储机制,需要取出来,进行本地展示,可以直接传到后台生成一个链接,直接在webview和浏览器里面打开,但是效果并不好,加载也慢些,所以就想到了用通过UIDocumentInteractionController来实现本地查看的操作,具体代码如下:...

weixin_33842304的博客 577

STM32F103用软件I2C读取IP2366电量数据,实测避坑指南(附完整源码)

本文详细介绍了如何使用STM32F103的软件I2C驱动读取IP2366电池管理芯片的电量数据,包括GPIO初始化、I2C时序实现、关键延时优化及常见问题解决方案。通过实测避坑指南和完整源码,帮助开发者快速实现稳定的电量数据读取,适用于嵌入式电池管理系统开发。

weixin_33725722的博客 524

企业数据治理体系中的AI与业务融合:架构师的3个成功案例

企业数据治理的痛点从来不是“有没有做”,而是“做了之后有没有用”——很多企业花了数百万建数据仓库、做元数据管理,最后却陷入“数据躺在库里睡大觉”“AI模型因数据质量差而失效”的困境。本文通过零售、金融、制造3个真实案例,拆解架构师如何用AI连接数据治理与业务场景:从“客户画像不准”到“精准推荐提升30%转化率”,从“欺诈检测漏报”到“实时拦截减少50%损失”,从“库存积压”到“供应链周转率提升20%”。如何让数据治理从「合规驱动」转向「价值驱动」?

AI 原生应用开发的博客 995

[记录]UIDocumentInteractionController不起作用,无法预览文件问题

我们首先先看代码: UIDocumentInteractionController *documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[ZQLog getLogFilePath]]]; self.documentInteractionController = documentInteractionControll

dingpwen的博客 1495

k8s 不同node之间pod ip不通

底层k8s使用calico网络,ipip网络模式,kubevirt启动了2台虚拟机;在这两台虚拟机上再搭建k8s,calico网络,ipip网络模式。说明:我是使用helm安装的calico,改这个模式要改crd资源ippools。其他方式安装的calico修改方法可能不一样。在虚拟机上的k8s上启动了2个pod,分布在不同的node上,这两个pod不能ping通对方的pod ip。修改虚拟机之上的k8s集群的calico网络的ipipMode为Never即可,之前使用的是Always。

weixin_40548182的博客 4061

iOS 两种预览使用详解(配Demo下载)( Quicklook& UIDocumentInteractionController)

一 Demo下载地址 二 使用 首先引入框架 将QLPreviewController设置为属性 初始化 设置代理和数据源 编码问题 个人小结 QLPreviewController使用细节 UIDocumentInteractionController presentOptionsMenuFromRect 和 presentOpenInMenuFromRect 的区别 QLPreviewContr

AI工程化、开源分享、文档翻译、代码笔记 3889

【C++】【STL算法】数据窄化及代码安全性

本文系统探讨了C++工程中数据窄化(narrowing conversion)的隐患与解决方案。数据窄化指将高精度/大范围类型转换为低精度/小范围类型,虽语法合法但会导致静默精度损失。其危险性体现在:错误隐蔽、STL会放大问题、数值错误具有传播性。现代C++要求窄化必须显式声明,文中提出四种工程解决方案:显式转换、边界统一转换、范围检查转换和使用GSL工具。建议在系统边界集中处理窄化,保持计算链路类型一致性,并通过分层策略(建模用double,控制用float)确保数值稳定性。核心思想是让窄化成为清晰可控的

Double Galaxy 82

YOLOv11改进策略【卷积层】| TIP 2025 MFA 多阶段特征聚合 大核扩感受 + 多梯度融合,强效增强弱小目标特征

红外弱小目标尺寸极小、信噪比低,在特征传递中极易丢失信息;常规卷积感受野单一、梯度源不足,难以同时捕捉局部细节与全局上下文,导致小目标特征表达弱、检测漏检。因此提出多阶段特征聚合 MFA,用大核卷积+多分支+通道注意力强化小目标特征提取。

Limiiiing的博客 597

iOS 文件下载保存预览功能实现

iOS 文件下载保存预览功能实现 保存到系统文件APP 文件预览

devil_0311的博客 1522

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

UIDocumentInteractionController浏览文件

之前写的一个项目打开文件直接用的UIWebView,word、excel、tex等等打开很方便。这次写项目用到了UIDocumentInteractionController,这是IOS提供的使用其他程序打开你的App不支持的文件格式。     UIDocumentInteractionController *documentInteractionController = [UIDocu

u013935547的博客 447

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

UIDocumentInteractionController

UIDocumentInteractionController UIDocumentInteractionController官方文档介绍如下: A view controller that previews, opens, or prints files whose file format cannot be handled directly by your app. 一个view contr...

了凡 2434

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

UIDocumentInteractionController 的使用

目前开发个文档预览的小功能,其中用到了沙盒机制和UIDocumentInteractionController iOS中的沙盒可以让平台更加的安全,这也是沙盒给用户带来的最主要好处。不过由于沙盒的严格限制,导致程序之间共享数据比较麻烦。一般在程序间共享文档可以通过UIDocumentInteractionController   UIDocumentInteractionController

进击的小果粉 1227

IOS开发 文件下载 文件预览

-(void)downloadFile:(NSString *)UrlAddress andWith:(NSString *)styleName11  { //UrlAddress 是下载链接 styleName11 是文件名+格式     NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithS

卢梦如的博客 1062

文件查看之UIDocumentInteractionController和UIWebView.WKWebView

iOS中的沙盒可以让平台更加的安全,这也是沙盒给用户带来的最主要好处。不过由于沙盒的严格限制,导致程序之间共享数据比较麻烦。一般在程序间共享文档可以通过UIDocumentInteractionController(该类经常被开发者忽略) UIDocumentInteractionController在iOS 3.2中就已经存在了,使用起来非常灵活,功能也比较强大。它除了支持同设备上app之间的文

Step_Next的博客 1556

iOS 打开本地或下载excel文件

打开本地或下载excel文件 1.用webView打开 - (UIWebView *)webView{ if (!_webView) { _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)]; _webView.backgro...

applexiaozhu的博客 3617

Dash-iOS终极文件分享指南:如何快速掌握UIDocumentInteractionController

Dash-iOS作为一款强大的iOS文档查阅工具,其文件分享功能基于UIDocumentInteractionController实现,为开发者提供了便捷的文档分享体验。这款应用专注于技术文档的离线下载与管理,让开发者能够随时随地查阅各种编程语言、框架和工具的文档集(DocSets),是iOS开发者的得力助手。✨ ## 🚀 什么是UIDocumentInteractionController

gitblog_00100的博客 457
上一篇: system 函数被废除的替代方法
下一篇: 解决 iOS 11 webview 顶部空白条的问题
sysprogram
博客等级 码龄17年 299粉丝 442原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址