关于UIDocumentInteractionController使用问题
1、调用问题
在使用UIDocumentInteractionController的时候不能使用局部变量形式调用。
比如
UIDocumentInteractionController * documentInteraction = [UIDocumentInteractionController interactionControllerWithURL:[NSURL URLWithString:fileLocalPath]];[documentInteraction presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];
这样调用后UIDocumentInteractionController 释放了界面就没了,你始终是调用不了。
解决方法:
你可以用成员变量形式来解决,代码如下
#pragma mark - Lazy
- (UIDocumentInteractionController *)documentInteraction{if (!_documentInteraction) {_documentInteraction = [[UIDocumentInteractionController alloc] init];_documentInteraction.delegate = self;}return _documentInteraction;
}//调用
self.documentInteraction.URL = [NSURL fileURLWithPath:filesLocalPath];
[self.documentInteraction presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];
2、点击其他App分享问题
2.1 点击后界面弹出个空界面。
不要在代理函数中如以下函数中调用释放UIDocumentInteractionController
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller;
释放代码
self.documentInteraction = nil;
因为有一些第三方App(word、QQ浏览器)要跳入其他App打开文件的,跳过去的时候他们就帮你把其关闭了。
会调用以上代码中的函数, 那UIDocumentInteractionController 释放了,第三方就打不开了。
千万不要写释放,利用ARC让其释放。
2.2 先点击一个分享后,回到App再点击分享后没有反应。
这种情况只发生在点击分享后,这个分享调用第三方App,并且UIDocumentInteractionController 没有关闭(有些分享会关有些不会关)。例如使用word App分享文件就不会关闭UIDocumentInteractionController。然后你回到自己的App的时候再点击分享就没有用了。(目前发现微信App 也存在这个问题)
解决方法:
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(nullable NSString *)application{[self.documentInteraction dismissMenuAnimated:YES];
}
在点击分享跳入第三方App 的时候统一关闭UIDocumentInteractionController。
关于UIDocumentInteractionController使用问题相关推荐
- iOS 文件预览 UIDocumentInteractionController
在应用开发中,有时候需要预览文档和视频,使用 UIDocumentInteractionController 来预览文件非常方便,支持的格式比较多,比如 docx.xlsx.pdf.mov.mp4.j ...
- UIDocumentInteractionController 文件预览
//创建并从底部弹出来 - (void)viewDidLoad { [super viewDidLoad]; [self setupDocumentControllerWithURL:fileURL] ...
- ios开发之--UIDocumentInteractionController的使用(实现更多分享服务)
最近在做项目的时候,碰到这样一个需求,就是本地生成pdf文件,然后本地打开,经过测试发现,pdf文件是无法保存到相册里面的,只能存到手机里面,鉴于苹果的存储机制,需要取出来,进行本地展示,可以直接传到 ...
- iOS 利用UIDocumentInteractionController打开和预览文档
iOS提供了使用其他app预览文件的支持,这就是Document Interaction Controller.此外,iOS也支持文件关联,允许其他程序调用你的app打开某种文件.而且,从4.2开始, ...
- iOS 两种预览使用详解(配Demo下载)( Quicklook UIDocumentInteractionController)
文章目录 二. 使用 1. 首先,引入框架 2. 将QLPreviewController设置为属性 3. 初始化 4. 设置代理和数据源 5. 编码问题 个人小结 QLPreviewControll ...
- iOS利用UIDocumentInteractionController和Quick Look打开或预览文档
在App的开发过程中,我们避免不了要打开软件中的文件,例如:Excel文件,Word文件,图片文件等不同格式的文件或者想要通过第三方的App来打开这些文件,那么我们就要用到UIDocumentInte ...
- app、H5、safari、appstore应用主页评分页之间拉起调用、打开手机某些系统功能、app打开文档
定义打开URL的方法 - (void)openURL:(NSString *)urlStr {NSURL *url = [NSURL URLWithString:urlStr];UIApplicati ...
- 开源中国iOS客户端学习——(一)Prefix.pch文件
2019独角兽企业重金招聘Python工程师标准>>> 当我们新建一个工程的时候,在Supporting FIles文件下会看到一个以 -Prefix.pch结尾文件的文件,pch ...
- iOS APP与APP之间的通信方式
为什么80%的码农都做不了架构师?>>> 1.URL Scheme 这个最常见了,基本接入分享.支付.地图的,都会用到 2.UIPasteboard 其实就是粘贴板,常见的就是 ...
最新文章
- 机房收费系统之uml图——初版
- lamp兄弟连视频笔记
- PADS Layout中的 无模式命令
- 数据监测驱动下的信息流广告优化
- c性能大容量cket_5千左右预算,既轻薄(高颜值)又高性能的笔记本推荐(畅玩LOL、CF、DNF、流放之路、梦幻西游)...
- mysql 账户管理_MySql 账户管理
- fileupload控件的属性_FileUpload控件的配置 .
- 英语口语练习软件测试简历,软件测试工程师个人简历英文版
- win10系统同时设置静态IP和动态IP
- java 读取写入excel_java读取和写入Excel文件
- PSI_压力阻塞信息
- 百度Java出现:“现在学java的都是傻子”相关搜索!
- 【干货】XSS知识总结
- 筑梦数字时代,城链科技战略峰会西安站顺利落幕
- webView加载白屏
- js网页点击播放背景音乐,再次点击暂停播放背景音乐
- unilife-fridge-producetion-show
- 神舟八号利用计算机进行飞行状态调整属于,“神舟八号”飞船利用计算机进行飞行状态调整属于____。...
- 图像处理之角点检测与亚像素角点定位
- 读懂 TS 中联合类型和交叉类型的含义
热门文章
- MATLAB:Meshgrid用法
- mac技巧|文件管理方法分享
- 32位ORACLE10G升级到 64位的ORACLE10G
- 图形界面画游戏泡泡机
- 某新商盟登录,js逆向:★★
- EasyExcel实现对excel文件读写
- 知识补充(原码、反码、补码)-- 一网打尽
- visio绘制立方体技巧
- 用不到1000美元攒一台深度学习用的超快的电脑:继续深度学习和便宜硬件的探奇!...
- vue stacic 和assets 得目录区别 转载一个可爱的作者 “你自人山人海中而来,原来只为了给我一场空欢喜。“ 你要去做一个大人,不要回头,不要难过。