2011-02-07 18 views

cevap

17

İşte Basit Bir Kod.

-(void)printItem { 

    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 0); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    [self.view.layer renderInContext:context]; 
    UIImage *imageFromCurrentView = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 

    UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController]; 
    printController.printingItem = imageFromCurrentView; 
    UIPrintInfo *printInfo = [UIPrintInfo printInfo]; 
    printInfo.outputType = UIPrintInfoOutputGrayscale; 
    printController.printInfo = printInfo; 
    printController.showsPageRange = YES; 


     void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { 
      if (!completed && error) { 
       NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code); 
      } 
     }; 

     [printController presentAnimated:YES completionHandler:completionHandler]; 

    } 
İlgili konular