文档说 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/