通过手机其他iOS应用打开此文件
根据所处理文档的格式,提供本地设备(InApp)能处理该格式文档的所有应用(App)。比如,demo中所处理的是pdf格式的文档,那么可以打开该文档的本地app有邮件、打印等等。仅支持ARC。
demo:
https://github.com/honkmaster/TTOpenInAppActivity
Requirements
- As
UIActivityis iOS 6 only, so is the subclass. - This project uses ARC. If you want to use it in a non ARC project, you must add the
-fobjc-arccompiler flag to TTOpenInAppActivity.m in Target Settings > Build Phases > Compile Sources.
Installation
Add the TTOpenInAppActivity subfolder to your project. Required libraries: UIKit, CoreGraphics, ImageIO and MobileCoreServices.
Usage.
- We keep a weak referemce to the superview (UIActionSheet). In this way we dismiss the UIActionSheet ans instead display the UIDocumentInterActionController.
TTOpenInAppActivityneeds to be initalized with the current view (iPhone & iPad) and a) a CGRect or b) a UIBarButtonItem (both only for iPad) from where it can present the UIDocumentInterActionController.- See example project.
NSURL *URL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"empty" ofType:@"pdf"]];
TTOpenInAppActivity *openInAppActivity = [[TTOpenInAppActivity alloc] initWithView:self.view andRect:((UIButton *)sender).frame];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:@[openInAppActivity]]; if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
// Store reference to superview (UIActionSheet) to allow dismissal
openInAppActivity.superViewController = activityViewController;
// Show UIActivityViewController
[self presentViewController:activityViewController animated:YES completion:NULL];
} else {
// Create pop up
self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
// Store reference to superview (UIPopoverController) to allow dismissal
openInAppActivity.superViewController = self.activityPopoverController;
// Show UIActivityViewController in popup
[self.activityPopoverController presentPopoverFromRect:((UIButton *)sender).frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
通过手机其他iOS应用打开此文件的更多相关文章
- XamarinSQLite教程Xamarin.iOS项目中打开数据库文件
XamarinSQLite教程Xamarin.iOS项目中打开数据库文件 以下是打开MyDocuments.db数据库的具体操作步骤: (1)将Mac电脑上的MyDocuments.db数据库移动到W ...
- (转)iOS安全 对本地文件的保护
开篇先扯几句题外话,许多朋友都问我怎么不写防啊,我确实有点犹豫.hackers总是想象如果自己是开发者会怎么写,然后才能找到入手点.同理,开发者们也要想象自己是hackers会怎么做,才能采取相应的防 ...
- 实现iOS图片等资源文件的热更新化(三):动态的资源文件夹
简介 此文,将尝试动态从某个不确定的文件夹中加载资源文件.文章,会继续完善自定义的 imageNamed 函数,并为下一篇文章铺垫. 这么做的意义 正如我们经常所说的那样,大多数情景知道做事的意义往往 ...
- android 打开各种文件(setDataAndType)转:
android 打开各种文件(setDataAndType) 博客分类: android-->非界面 android 打开各种文件 setDataAndType action动作 转自:htt ...
- iOS开发-- 创建podspec文件,为自己的项目添加pod支持
开篇扯淡 作为一个iOS开发者,一定用过CocoaPods吧,没用过?点这儿去面壁吧 Cocoapods作为iOS开发的包管理器,给我们的开发带来了极大的便利,而且越来越多的第三方类库支持Pod,可以 ...
- ios项目生成ipa文件方法
做这些的前提是你配置好了所有的证书,如果还没先去配置证书吧. 1.打开需要生成ipa的ios项目.2.在运行按钮的后面选择ios Device3.点击Product 按钮,选择第五个Archive4. ...
- (转)IOS之Info.plist文件简介
原文:IOS之Info.plist文件简介 http://www.apkbus.com/android-130240-1-1.html (出处: Android开发论坛 - 安卓开发论坛 - Andr ...
- Android(java)学习笔记143:android提供打开各种文件的API接口:setDataAndType
android 打开各种文件(setDataAndType) private void openFile(File file){ Intent intent = new Intent(); inten ...
- (转)iOS学习之 plist文件的读写
在做iOS开发时,经常用到到plist文件, 那plist文件是什么呢? 它全名是:Property List,属性列表文件,它是一种用来存储串行化后的对象的文件.属性列表文件的扩展名为.plist ...
随机推荐
- Python 极简教程(十一)字典 dict
字典是以大括号标识,以键值对(key:value)的形式,无序,不可重复,可变的集合类型. 字典具有非常高效的读写效率. >>> d = {} # 创建一个空字典 >>& ...
- python 的spyder用法
ctrl+tab可以进行跳转 https://blog.csdn.net/luckygirl0809/article/details/79929491
- multi_input_paths
- 宏定义#define整理
一.宏定义#define 优点:一方面可以节省程序的空间上的篇幅,另外,恰当地使用宏定义可提高程序的时间效率.代码可以写的通俗易懂.可以提高程序的清晰性.可读性,使于修改移植等. 缺点:宏定义的使用实 ...
- JNI各种环境下编译方法及初期出错分析
转自 https://www.cnblogs.com/xyang0917/p/4172490.html 第五步.将C/C++代码编译成本地动态库文件 动态库文件名命名规则:lib+动态库文件名+后缀( ...
- 视频编码器评測系统:VideoCodecRank
视频编码器领域一直有个比較复杂的问题:mpeg2.divx.xvid.mpeg4.vp8.vp9.x264.openh264.x265等等这一系列编码器究竟哪个好?而对于同一种视频编码器,又包括了各种 ...
- 2019年Angular7——安装搭建路由
Angular 中文官方:https://www.angular.cn/ 为什么要看Angular?我也不知道,因为公司有个Angular的项目要维护.听说Angular的版本已经到7了.以前没怎么玩 ...
- [Angular] HostListener Method Arguments - Blocking Default Keyboard Behavior
We are going to see how to using method arguments for @HostListener. First, we can use HostListener ...
- struts2注入类
struts2是能够注入一个对象的,那么一定须要继承ModelDriven的泛型接口. package com.test.action; import com.opensymphony.xwork2. ...
- 手把手教你----MyEclipse中 配置 Tomcat
电脑上配置Tomcatserver 安装Tomcat并配置环境变量 測试是否配置成功 MyEclipse中配置Tomcat 想要开发Java Web的程序.首先在MyEclipse中必须配置Tomca ...