iphone - 以编程方式检索支持给定文件类型的已安装应用程序列表

标签 iphone ios ipad uidocumentinteraction protocol-handler

虽然很明显我们无法检索 iOS 上已安装应用程序的列表,但是否有任何技巧可以让我们确定为给定文件类型注册的应用程序列表?也就是说,用户将在“打开方式...”菜单中看到该特定文件类型的列表。 canOpenURL 只返回一个 bool 值,但理想情况下它会返回我们支持的已安装应用程序列表。

最佳答案

UIDocumentInteractionController当然可以打开你只需要实例化 UIDocumentInteractionController 实例:

//Following in header file:
UIDocumentInteractionController *docInteractionController;

实现委托(delegate):

<UIDocumentInteractionControllerDelegate>

.m:

//Here the url is the document URL that you want to open (or you want to apply open in functionality)
self.docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docInteractionController.delegate = self;

打开方式如下:

- (void) openIn: (id) sender {
    [self.docInteractionController presentOptionsMenuFromBarButtonItem:sender animated:YES];
}

完成后:

[self.docInteractionController dismissMenuAnimated:YES];

就是这样。这将列出文档支持的应用程序列表,并且在选择它们时将使用我们实例化的文档 URL 启动相应的应用程序。

关于iphone - 以编程方式检索支持给定文件类型的已安装应用程序列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9985576/

相关文章:

ios - showsReorderControl 有什么意义?

ios - 在 NSUserDefaults 中存储 NSArray 时应用程序崩溃

iOS计算tableView单元格中的文本高度

iphone - 关闭 MPMoviePlayerViewController 的全屏模式时出现问题

iphone - 像iOS一样的App Store

iphone - 如何清除缓存图片?

iphone - 从一个方法中设置的属性访问另一个方法的值

ios - AutoLayout Size Classes - 不同的比例高度

java - Java 和 Objective C 的 LateX 渲染

Iphone Objective C - 在点击我的 UITableViewCell 后 resignFirstResponder