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];
}