iphone - UIDocumentInteractionController : open file whith native application

标签 iphone ios

文档说 UIDocumentInteractionController 允许使用已安装的应用程序隐式打开文件(UTI 属性为 nil),但不是 native 的。

UIDocumentInteractionController *controller = [UIDocumentInteractionController  interactionControllerWithURL:fileURL];
[controller retain];
controller.delegate = self;
//controller.UTI = uti;

CDVViewController* cont = (CDVViewController*)[ super viewController ];
CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
[controller presentOpenInMenuFromRect:rect inView:cont.view animated:YES];

是否可以在 Safari 中打开 pdf 文件或在图库中打开图像?

附言我是 Objective C 的新手 :)

最佳答案

不可能告诉设备什么应用程序必须打开您的文件。

你可以使用 UIApplication's OpenUrl method例如打电话,或者用一些 url 启动 Safari .. 例如:

[[UIApplication sharedApplication] openURL:@"tel://%i", someNumber];

但是如果你想打开一个特定的文件,你必须使用 UIDocumentInteractionController

还有QLPreviewController用于预览文档的 API。 <强> Here 是如何使用它以及查看它的外观的教程。

关于iphone - UIDocumentInteractionController : open file whith native application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15808536/

相关文章:

iphone - 动态生成 UITableViews

iphone - 同时使用 AVPlayer 播放视频并使用 AVAudioRecorder 录制声音

iphone - 在iPhone上从0到3保存数字长链(NSArray),这是一种有效的方法

iOS 定期后台位置更新,这不仅取决于重大的位置变化

iphone - 应用程序在 iphone 上运行良好但在模拟器中失败

ios - 在另一个表的 FooterView 内添加 UITableView(在添加的 UITableView 上未调用 didSelectRowAtIndexPath)

iphone - 如何在 iPhone 上移动 MkMapView.userLocation?

ios - 关闭键盘的平滑过渡

ios - 从 paypal ios sdk 获取访问 token 时客户端凭据无效

ios - 从 HSB 光谱的限制范围获取 UIColor