根据所处理文档的格式,提供本地设备(InApp)能处理该格式文档的所有应用(App)。比如,demo中所处理的是pdf格式的文档,那么可以打开该文档的本地app有邮件、打印等等。仅支持ARC。

demo:

https://github.com/honkmaster/TTOpenInAppActivity

Requirements

  • As UIActivity is 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-arc compiler 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.
  • TTOpenInAppActivity needs 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应用打开此文件的更多相关文章

  1. XamarinSQLite教程Xamarin.iOS项目中打开数据库文件

    XamarinSQLite教程Xamarin.iOS项目中打开数据库文件 以下是打开MyDocuments.db数据库的具体操作步骤: (1)将Mac电脑上的MyDocuments.db数据库移动到W ...

  2. (转)iOS安全 对本地文件的保护

    开篇先扯几句题外话,许多朋友都问我怎么不写防啊,我确实有点犹豫.hackers总是想象如果自己是开发者会怎么写,然后才能找到入手点.同理,开发者们也要想象自己是hackers会怎么做,才能采取相应的防 ...

  3. 实现iOS图片等资源文件的热更新化(三):动态的资源文件夹

    简介 此文,将尝试动态从某个不确定的文件夹中加载资源文件.文章,会继续完善自定义的 imageNamed 函数,并为下一篇文章铺垫. 这么做的意义 正如我们经常所说的那样,大多数情景知道做事的意义往往 ...

  4. android 打开各种文件(setDataAndType)转:

    android 打开各种文件(setDataAndType) 博客分类: android-->非界面 android 打开各种文件 setDataAndType action动作  转自:htt ...

  5. iOS开发-- 创建podspec文件,为自己的项目添加pod支持

    开篇扯淡 作为一个iOS开发者,一定用过CocoaPods吧,没用过?点这儿去面壁吧 Cocoapods作为iOS开发的包管理器,给我们的开发带来了极大的便利,而且越来越多的第三方类库支持Pod,可以 ...

  6. ios项目生成ipa文件方法

    做这些的前提是你配置好了所有的证书,如果还没先去配置证书吧. 1.打开需要生成ipa的ios项目.2.在运行按钮的后面选择ios Device3.点击Product 按钮,选择第五个Archive4. ...

  7. (转)IOS之Info.plist文件简介

    原文:IOS之Info.plist文件简介 http://www.apkbus.com/android-130240-1-1.html (出处: Android开发论坛 - 安卓开发论坛 - Andr ...

  8. Android(java)学习笔记143:android提供打开各种文件的API接口:setDataAndType

    android 打开各种文件(setDataAndType) private void openFile(File file){ Intent intent = new Intent(); inten ...

  9. (转)iOS学习之 plist文件的读写

    在做iOS开发时,经常用到到plist文件, 那plist文件是什么呢? 它全名是:Property List,属性列表文件,它是一种用来存储串行化后的对象的文件.属性列表文件的扩展名为.plist ...

随机推荐

  1. Android SocketService

    package com.freer.infusion.module.service; import android.app.ActivityManager; import android.app.Pe ...

  2. 未能加载文件或程序集“System.Collections.Concurrent”或它的某一个依赖项。

    未能加载文件或程序集“XXXXXX”或它的某一个依赖项.试图加载格式不正确的程序.   在本机WIN7机器上的WebService部署到Win2008R2上发现错误 “/”应用程序中的服务器错误. 未 ...

  3. Qt开发程序在Windows 10应用须要管理员执行的解决思路

    Qt开发程序在Windows 10应用须要管理员执行的解决思路 过了非常长的时间没有公布博客了.可是我依旧努力地开发Qt程序.眼下呢.我发现开发Qt程序在Windows 10上有一个怪现象--有些程序 ...

  4. 缓存(cache)的理解

    缓存的特点: 读取速度很快,容量相比硬盘较小: 缓存在实现时,本质上仍然是一块内存区域: cache 机制的一个核心关注点还在于,究竟什么样的数据应该放在缓存中,显然不是所有,那就应当是部分,就应该是 ...

  5. 一次性能优化将filter转换

    有一条SQL性能有问题,在运行计划中发现filter.遇到它要小心了,类似于nestloop.我曾经的blog对它有研究探索运行计划中filter的原理.用exists极易引起filter. 优化前: ...

  6. LoaderManager使用具体解释(一)---没有Loader之前的世界

    来源: http://www.androiddesignpatterns.com/2012/07/loaders-and-loadermanager-background.html 感谢作者Alex ...

  7. GDB(十)--调试正在运行的进程

    我编写了一个循环: long i;    for (i = 0; i < 999999; i++) {        mt.a += 1;        sleep(1);    }把它编译成a ...

  8. [ES7] Await multi promises sequentially or concurrently

    Somtime 'async await' can have a bad effect on code proferemence. Let's take a look the below exampl ...

  9. ios开发之级联菜单(两个tableView实现)

    一:在ios项目实际开发中经常会看到级联菜单的效果:如图:点击左侧菜单,右侧菜单刷新数据.此篇用两个tableView来实现如图效果: 二:代码: 1:构造数据模型:利用kvc快速构建数据模型 #im ...

  10. apche commons项目简介 分类: B1_JAVA 2014-06-26 11:27 487人阅读 评论(0) 收藏

    1.apche commons项目封装了日常开发中经常使用的功能,如io, String等. http://commons.apache.org/ Apache Commons项目的由三部分组成: T ...