4
안녕하세요, 저는 UITableView를 인쇄 할 수있는 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(UIUserInterfaceIdiomPad == [[UIDevice currentDevice] userInterfaceIdiom]){
[printer presentFromRect:printButton.frame inView:self.view animated:YES completionHandler:completionHandler];
} else {
[printer presentAnimated:YES completionHandler:completionHandler];
}