Search code examples
iosipadpopoverpreviewairprint

Application tried to present inside popover with transition style other than UIModalTransitionStyleCoverVertical before printing


I am trying to print a txt file from within a iPad 8.x application. So, I have this code:

- (void)onOpenWith:(UIButton *)theButton path:(NSString *)path
{


    NSURL *URL = [NSURL fileURLWithPath:path];

    if (URL) {



        self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];

        self.documentInteractionController.delegate = self;
        [self.documentInteractionController presentPreviewAnimated:YES];

    }
}

#pragma mark - UIDocumentInteractionControllerDelegate

- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
    return self;
}

- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
    return self.view;
}

- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
    return self.view.frame;
}

Now everything is going as expected, I see a preview of the file, then I touch the icon on the top right corner of the screen and I am able to share the document in those applications that can handle it. However, if I touch PRINT I get this error message:

Application tried to present inside popover with transition style other than UIModalTransitionStyleCoverVertical

and the app crashes. Sure, i understand it, but to which viewcontroller should I apply this transition? I have no control on the popover showing the print dialog...

In iOS 7 (real iPad not simulator) everything works...

Can anybody help me?

Thanks Fabio


Solution

  • I also came across this issue, and the solution was that I had to build and run my app with Xcode 6 installed.

    On my older machine, I have Xcode 5.1.1, and when run from there, this same issue appeared, and some more issues from this view (like cannot dismiss mail controller when opened from the top right corner).