2
我有以下的打印代碼,我希望它打印類連接到視圖控制器的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];
}