My code is :
UIPrintInfo *pi = [UIPrintInfo printInfo];
pi.outputType = UIPrintInfoOutputGeneral;
NSString *url=[[req URL] absoluteString];
pi.jobName = url;
pi.orientation = UIPrintInfoOrientationPortrait;
pi.duplex = UIPrintInfoDuplexLongEdge;
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.printInfo = pi;
pic.delegate=self;
pic.showsPageRange = YES;
pic.printFormatter = self.webView.viewPrintFormatter;
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[pic presentFromRect:CGRectMake(64, 64, self.view.frame.size.width, self.view.frame.size.height-64) inView:self.view animated:YES completionHandler:^(UIPrintInteractionController* pic2, BOOL completed, NSError* error) {
}];
});
It is presenting fine, but when the cancel button is clicked to dismiss the view it crashed with the message:
Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now