gpt4 book ai didi

iphone - 如何检查 UIDocumentInteractionController 是否由于在 iPad 上缺少外部应用程序而无法打开文档?

转载 作者:太空狗 更新时间:2023-10-30 03:14:25 25 4
gpt4 key购买 nike

我正在使用 UIDocumentInteractionController 显示弹出菜单“打开方式...”,以便用户可以在其他应用程序中打开文档。

方法 presentOpenInMenuFromBarButtonItem:animated: 返回 NO 如果没有应用程序能够打开给定的文档(菜单将不会显示)。但我等到这一步已经来不及了。如果不可能,我想禁用启动该打开的按钮,而不是提高用户的期望,然后说“抱歉,无法打开它”。

是否可以查询系统以查看是否至少有一个应用程序注册了特定的文档类型?我已经检查了 canPreviewItem: in QLPreviewController,但它似乎不支持 UIDocumentInteractionController 可以处理的相同文档类型。

最佳答案

[编辑] 不适用于 iOS 6.0(见评论)

似乎 dismissMenuAnimated(根本没有动画)是关键:

-(BOOL)canOpenDocumentWithURL:(NSURL*)url inView:(UIView*)view {
BOOL canOpen = NO;
UIDocumentInteractionController* docController = [UIDocumentInteractionController
interactionControllerWithURL:url];
if (docController)
{
docController.delegate = self;
canOpen = [docController presentOpenInMenuFromRect:CGRectZero
inView:self.view animated:NO];
[docController dismissMenuAnimated:NO];
}
return canOpen;
}

如果至少有一个应用程序能够打开 url 指向的文件,它将返回 YES。至少它在我的情况下(KMZ 文件)有效,在 iPhone iOS 4.3 上使用/不使用 Dropbox 应用进行测试。
实际上,即使 url 未指向实际文件(即 @"test.kmz"),它似乎也能正常工作,但我不会对所有文件类型都依赖它。

关于iphone - 如何检查 UIDocumentInteractionController 是否由于在 iPad 上缺少外部应用程序而无法打开文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4957980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com