虽然很明显我们无法检索 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/