要求:我有一个名为wkWebView
的WKWebview
对象。我想使用 Airprint 从我的打印机打印它的内容。我曾经使用 UIWebview
执行此操作,但运行时 javascript 方法的要求让我切换到 WKWebview
。
@property (strong, nonatomic) WKWebView *wkWebView;
问题:我可以使用下面的代码打印内容。当我打印一页时,它打印得很完美。但是当我尝试打印 2 页时,第 2 页先打印,然后是第 1 页。我想按顺序打印页面。
代码:我目前在我的打印方法中使用这段代码:
UIPrintInfo *pi = [UIPrintInfo printInfo];
pi.outputType = UIPrintInfoOutputGrayscale;
pi.orientation = UIPrintInfoOrientationPortrait;
pi.duplex = UIPrintInfoDuplexNone;
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.printInfo = pi;
pic.showsPageRange = YES;
pic.showsNumberOfCopies = NO;
pic.printFormatter = _wkWebView.viewPrintFormatter;
UIButton *butn = (UIButton*)sender;
[pic presentFromRect:butn.frame
inView:self.view
animated:YES
completionHandler:^(UIPrintInteractionController *printInteractionController, BOOL completed, NSError *error) {
//Do something
}];
最佳答案
您是否尝试过单独打印页面?
我会将它们放在数组中,然后检查数组长度并运行代码以在 For 循环中打印页面。
关于ios - 从 WKWebView 打印 2 页时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32978649/