【问题标题】:UIDocumentInteractionController presentOptionsMenuFromBarButtonItem don't open appUIDocumentInteractionController presentOptionsMenuFromBarButtonItem 不打开应用
【发布时间】:2015-10-16 05:54:33
【问题描述】:

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

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

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

谢谢

【问题讨论】:

  • UIActivityController 有什么问题?

标签: ios uidocumentinteraction open-with


【解决方案1】:

我通常是这样做的:

   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];

    }

【讨论】:

  • 感谢您的回答,但 presentOpenInMenuFromRect 仅适用于其他应用程序(Adobe Reader 打开没有任何问题)。它没有显示通过邮件发送文档或打印文档的任何选项。
  • 我已经使用了 presentOptionsMenuFromBarButtonItem(这是我的第一选择),但有几次它没有打开 Adob​​e Reader(或任何其他应用程序)。它仅适用于邮件和打印。我用 documentController.UTI = @"com.adobe.pdf"; 设置了 UTI
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-05
相关资源
最近更新 更多