ios - UIDocumentInteractionController PresentOptionsMenuFromBarButtonItem 不打开应用程序

标签 ios uidocumentinteraction open-with

我使用 UIDocumentInteractionController PresentOptionsMenuFromBarButtonItem 在 Adob​​e Reader 应用程序中打开 PDF,通过邮件发送并打印。邮件和打印工作正常,但我无法打开任何其他应用程序。我尝试了presentOpenInMenuFromBarButtonItem 和UIActivityViewController 但它们都不能满足我的需要。

我尝试使用 documentInteractionController: willBeginSendingToApplication: delegate 打开 Adob​​e Reader,但我无法找到如何将 pdf 传递到应用程序。可能吗?

如果没有,是否有另一种方法可以在 Adob​​e Reader 应用程序中打开 PDF,通过邮件发送并打印?

谢谢

最佳答案

通常我是这样做的:

   NSURL *documentsDirectoryPath = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]];

    NSURL *URL =[documentsDirectoryPath URLByAppendingPathComponent:@"your pdf"];

    UIButton *button = (UIButton *)nil;
    self.documentInteractionController.delegate=self;
    if (URL) {
        // Initialize Document Interaction Controller
        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
        // Configure Document Interaction Controller
        [self.documentInteractionController setDelegate:self];
        //preview
       [self.documentInteractionController presentPreviewAnimated:YES];
        // Present Open In Menu
        [self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES];

    }

关于ios - UIDocumentInteractionController PresentOptionsMenuFromBarButtonItem 不打开应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33156525/

相关文章:

ios - iOS 中切换推送通知的 UX

ios - Whatsapp 图像共享不起作用

ios iphone hooks直接打开instagram而不显示UIDocumentInteractionController

c# - "Open with"- C# 程序在 Windows "Open With"上下文菜单中只显示图标

Java 编辑器无法打开我的 java 代码

ios - 类型 "viewController"不符合协议(protocol) "PathMenuDelegate"

ios - 将上下文传递给多个 InterfaceControllers?

ios - 如何在 PST Collectionview 中突出显示选定的单元格?

ios - 文档交互 Controller

windows - 如何在打开方式对话框中启用 “Always use the selected program to open this kind of file” 选项