DocumentInteractionController

DocumentInteractionController

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

我试图用documentInteractionController:willBeginSendingToApplication:代理打开Adobe Reader,但是我找不到如何将pdf传递给应用程序。可能吗?

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

谢谢

最佳答案

通常,这就是我的工作方式:

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

    }

09-12 06:46