2012-01-06 100 views

回答

0

UIPrintInteractionController * PIC = [UIPrintInteractionController sharedPrintController]

如果(PIC & & [UIPrintInteractionController canPrintData:self.myPDFData]){

pic.delegate = self; 

UIPrintInfo *printInfo = [UIPrintInfo printInfo]; 

printInfo.outputType = UIPrintInfoOutputGeneral; 

printInfo.jobName = @"PrintPdf"; 

printInfo.duplex = UIPrintInfoDuplexLongEdge; 

pic.printInfo = printInfo; 

pic.showsPageRange = YES; 

pic.printingItem = self.myPDFData; 

void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = 

^(UIPrintInteractionController *pic, BOOL completed, NSError *error) { 

    if (!completed && error) 

     NSLog(@"FAILED! due to error in domain %@ with error code %ld", 

       error.domain, (long)error.code); 
}; 
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 

    [pic presentFromRect:self.printButton.frame inView:self.view animated:YES completionHandler:^(UIPrintInteractionController *printInteractionController, BOOL completed, NSError *error) { 
    }]; 

} else { 
    [pic presentAnimated:YES completionHandler:completionHandler]; 
} 

}

相关问题