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!
ios uikit ipad
Abdulmalik morghem
source share