从WKWebView打印2页时出现问题

Nis*_*ant 9 printing objective-c ios wkwebview

要求:我有一个WKWebview叫做的对象wkWebView.我想使用Airprint从我的打印机打印其内容.我曾经这样做,UIWebview但运行时javascript方法的要求让我切换到WKWebview.

@property (strong, nonatomic) WKWebView *wkWebView;
Run Code Online (Sandbox Code Playgroud)

问题:我可以使用下面的代码打印内容.当我打印1页时,它打印得很完美.但是当我尝试打印2页时,第2页首先打印,然后打印第1页.我想按顺序打印页面.

代码: 我目前在我的print方法中使用此代码:

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
   }];
Run Code Online (Sandbox Code Playgroud)

小智 -3

您是否尝试过单独打印页面?

我会将它们放入数组中,然后检查数组长度并运行代码以在 For 循环内打印页面。