Search code examples
iosuipopovercontrollerairprint

How do I Implement printInteractionControllerParentViewController: with a popover?


I'm implementing printInteractionControllerParentViewController: as required by UIPrintInteractionControllerDelegate to customise the popover showing the print options. Which this is ran, the popover appears at the size of the full height of the (portrait) iPad, before shrinking down to the normal size.

Any advice on how to have the popover appear in a more sensible way would be helpful.

Here's my implementation:

- (UIViewController*)printInteractionControllerParentViewController:(UIPrintInteractionController*)printInteractionController {
    UINavigationController* navigationController = [[UINavigationController alloc] init];

    popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
    [popover setPopoverBackgroundViewClass:[CustomPopoverBackgroundView class]];

    [popover presentPopoverFromRect:_printButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    [popover.contentViewController.view setBackgroundColor:backgroundColor];

    return navigationController;
}

Solution

  • Try setting the contentSizeForViewInPopover for the viewcontroller:

    yourViewController.contentSizeForViewInPopover = CGSizeMake(320.0, 750.0);
    

    You could set this when you initialize our controller.