弹出Airprint对话框,但在日志屏幕中它显示两个警告:
1)警告:在iPad上调用 – [UIPrintInteractionController presentAnimated:completionHandler:]
找不到PDF标题:找不到`%PDF’.
2)[UIPopoverController_commonPresentPopoverFromrect:
inView:allowedArrowDirections:animated:]:传入此方法的rect必须具有非零的宽度和高度.这将是未来版本中的一个例外.
我已经在网上搜索过,但发现所有解决方案都提供了常规的rect按钮
我在这里使用的是一个分段控件,我不知道在这种情况下如何使用这个控件
这是段控制代码:
- (IBAction)legalSegment:(id)sender { switch (((UISegmentedControl *)sender).selectedSegmentIndex) { case 0: { [self printItem]; break; } }
这是printItem方法:
-(void)printItem { CGRect rect = CGRectMake(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]; } }
任何帮助都会很棒.
提前致谢 !
解决方法
presentAnimated:completionHandler:
Presents the iPhone printing user interface in a sheet that can be
animated to slide up from the bottom of the screen.
presentFromBarButtonItem:animated:completionHandler:
Presents the iPad printing user interface in a popover view that can
be animated from a bar-button item.
presentFromrect:inView:animated:completionHandler:
Presents the iPad printing user interface in a popover view that can
be animated from any area in a view.
您应该在相应的设备类型上使用正确的方法.
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { [pic presentFromrect:self.view.frame inView:self.view animated:YES completionHandler:completionHandler]; } else { [pic presentAnimated:YES completionHandler:completionHandler]; }
您应该为弹出窗口演示使用适当的参数.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。