UIDocumentInteractionController在没有选项的特定应用程序中打开文件

时间:2011-07-24 15:36:33

标签: ios iphone objective-c handler uidocumentinteraction

我正在使用UIDocumentInteractionController在另一个应用DropBox中打开文件。

我尝试做的是在另一个特定应用中打开该文件,但我目前只管理显示支持的应用并允许用户选择。

UIDocumentInteractionController *udi = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath: jpgPath]];
[udi retain];
CGRect r = CGRectMake(0, 0, 300, 300);
[udi presentOpenInMenuFromRect:r inView:self.view animated:YES];

这会显示支持的应用列表,但我想直接使用dropbox打开文件,而不使用选项框。有什么想法吗?

2 个答案:

答案 0 :(得分:1)

我很高兴自相矛盾,但我认为这是不可能的(至少包括iOS 4在内)。

在另一个应用程序中打开文件的常规方法是使用自定义URL方案。 (请参阅UURpplication类参考中的openURL文档:以及iOS应用程序编程指南中的Implementing Custom URL Schemes。)据我所知,Dropbox尚未实现自定义URL方案。而且,鉴于此,这种方法已经结束。

UIDocumentationController非常不透明。您可以将其哄骗到telling you whether or not there is any application on the device that will open your file。但目前尚不清楚你能做多少其他事情。

答案 1 :(得分:-1)

如果您想在特定应用中提供开放文件,只需添加(使用swift 3.0):

docController.uti = @"com.dropbox.ios";