Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ([UIPrintInteractionController isPrintingAvailable]) {
- UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
- pic.delegate = self;
- UIPrintInfo *printInfo = [UIPrintInfo printInfo];
- printInfo.outputType = UIPrintInfoOutputGeneral;
- printInfo.jobName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
- pic.printInfo = printInfo;
- UIViewPrintFormatter* printFormatter = articleWebView.viewPrintFormatter;
- pic.printFormatter = printFormatter;
- pic.showsPageRange = NO;
- if([pic respondsToSelector:@selector(showsNumberOfCopies)]) {
- pic.showsNumberOfCopies = NO;
- }
- void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
- if (!completed && error) {
- NSLog(@"Printing could not complete because of error: %@", error);
- }
- };
- CGRect senderFrame = ((UIButton*)sender).frame;
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- [pic presentFromRect:senderFrame inView:self.view animated:YES completionHandler:completionHandler];
- } else {
- [pic presentAnimated:YES completionHandler:completionHandler];
- }
- } else {
- NSLog(@"WARN: printing is not available");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement