[IOS 开发] 关于ios打印(AirPrint)

2019-04-15 13:36发布

导入 UIPrintInteractionController 类 在.h中实现它的代理Delegate
例子: UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; if (pic) { pic.delegate = self; UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputGeneral; printInfo.jobName = @"111"; printInfo.duplex = UIPrintInfoDuplexLongEdge; pic.printInfo = printInfo; pic.showsPageRange = YES; //可以是多张图片 pic.printingItems = dataArr; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =^(UIPrintInteractionController *pic, BOOL completed, NSError *error) { if (!completed && error) NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code); }; if (iPad) { [pic presentFromRect:sender.frame inView:self.window animated:YES completionHandler:completionHandler]; }else { [pic presentAnimated:YES completionHandler:completionHandler]; } }