UIPrintInteractionController on iPad gives me two warnings

I use code to get Airprint in my application to print the current image as an image. the Airprint dialog appears, but on the log screen it shows me two warnings:

1) WARNING: Call - [UIPrintInteractionController presentAnimated: completeHandler:] on the iPad could not find the PDF header: `% PDF not found.

2) [UIPopoverController_commonPresentPopoverFromRect: inView: allowedArrowDirections: animated:]: the relay passed to this method must have a non-zero width and height. This will be an exception in a future version.

I already searched the net, but found that all the solutions provided for the regular button buttons

what i use here is a segmented control and i don't know how to use this control in this situation

here is the segment control code:

- (IBAction)legalSegment:(id)sender { switch (((UISegmentedControl *)sender).selectedSegmentIndex) { case 0: { [self printItem]; break; } } 

and this is the printItem method:

 -(void)printItem { CGRect rect = CGRectMake(0, 0, 768, 1004); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.view.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIPrintInteractionController* pic = [UIPrintInteractionController sharedPrintController]; NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(img)]; if (pic && [UIPrintInteractionController canPrintData:imageData]) { pic.delegate = self; UIPrintInfo* printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputPhoto; printInfo.jobName = @"PrintingImage"; printInfo.duplex = UIPrintInfoDuplexLongEdge; pic.printInfo = printInfo; pic.showsPageRange = YES; pic.printingItem = imageData; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { if (!completed && error) { NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code); } }; [pic presentAnimated:YES completionHandler:completionHandler]; } } 

any help would be great. Thanks in advance!

+7
ios uikit ipad
source share
1 answer

On iPad, you must use the popover API provided by the controller. This is indicated in the documentation.

presentAnimated:completionHandler:

Represents the user interface for printing iPhone on a sheet, which can be animated to move up from the bottom of the screen.

presentFromBarButtonItem:animated:completionHandler:

Represents the iPad print user interface in a popover view that can be animated from a panel item.

presentFromRect:inView:animated:completionHandler:

Represents the iPad print user interface in a popover view, which can be animated from any area in the view.

You must use the correct method for the appropriate device type.

 if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { [pic presentFromRect:self.view.frame inView:self.view animated:YES completionHandler:completionHandler]; } else { [pic presentAnimated:YES completionHandler:completionHandler]; } 

You must use the appropriate options for the presentation popover.

+15
source share

All Articles