olivierplante
olivierplante

Reputation: 175

UIDocumentInteractionController presentOptionsMenuFromBarButtonItem don't open app

I use UIDocumentInteractionController presentOptionsMenuFromBarButtonItem to open PDF in Adobe Reader app, send it with Mail and print it. Mail and print work fine but I'm unable to open any other app. I tried presentOpenInMenuFromBarButtonItem and UIActivityViewController but neither of them do all I need.

I tried to open Adobe Reader with documentInteractionController: willBeginSendingToApplication: delegate but i'm unable to find how I can pass the pdf to the app. Is it possible?

If not, is there a another way to open PDF in Adobe Reader app, send it with Mail and print it?

Thanks

Upvotes: 2

Views: 2473

Answers (1)

Teja Nandamuri
Teja Nandamuri

Reputation: 11201

Normally this is how I do:

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

    }

Upvotes: 2

Related Questions