我有以下用于打印的代码,我希望它打印该类所附加到的视图控制器的 UIVIew,
但打印只会生成空白页(和两页而不是一页)
我对xcode还很陌生,你能帮忙找出错误吗?
UIPrintInteractionController *pc = [UIPrintInteractionController
sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"Print file";
pc.printInfo = printInfo;
UIViewPrintFormatter *Pformatter = [self.view viewPrintFormatter];
pc.printFormatter = Pformatter;
UIPrintInteractionCompletionHandler completionHandler =
^(UIPrintInteractionController *printController, BOOL completed,
NSError *error) {
if(!completed && error){
NSLog(@"Print failed - domain: %@ error code %u", error.domain,
error.code);
}
};
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[pc presentFromBarButtonItem:self.btnPrint animated:YES
completionHandler:completionHandler];
} else {
[pc presentAnimated:YES completionHandler:completionHandler];
}