大佬教程收集整理的这篇文章主要介绍了ios – 打印屏幕内容的UITableView?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我用来打印的代码:
UIGraphicsBeginImageContext(self.mainTableView.contentSizE); [self.mainTableView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIPrinTinteractionController *printer = [UIPrinTinteractionController sharedPrintController]; printer.prinTingItem = viewImage; UIPrinTinfo *info = [UIPrinTinfo prinTinfo]; printer.prinTinfo = info; UIPrinTinteractionCompletionHandler completionHandler = ^(UIPrinTinteractionController *pic,BOOL completed,NSError *error) { if (!completed && error) NSLog(@"Failed! due to error in domain %@ with error code %u: %@",error.domain,error.code,[error localizedDescription]); }; UIButton * printButton = (UIButton *)sender; if(UIUserInterfaceI@L_288_5@mPad == [[UIDevice currentDevice] userInterfaceI@L_288_5@m]){ [printer presentFromRect:printButton.frame inView:self.view animated:YES completionHandler:completionHandler]; } else { [printer presentAnimated:YES completionHandler:completionHandler]; }
SO: Screenshot from a UITableView
SO: How to take an iPhone screenshot of entire view including parts off screen
问题是,UITableViews重用它们的单元格.
我认为最常见的方法是:
>以编程方式滚动到UITableView的不同部分,拍摄不同的屏幕截图并将它们再次合并在一起.>调整UITableView的大小,以便所有单元格都适合它.警告:这很快就会导致内存问题(不再需要重复使用单元),所以只是为了屏幕截图而且你的单元数不是那么大.
以上是大佬教程为你收集整理的ios – 打印屏幕内容的UITableView?全部内容,希望文章能够帮你解决ios – 打印屏幕内容的UITableView?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。