1
我使用UIPrintInteractionController
打印從UIWebView
一個html直接連接到打印機支持AirPrint。我想告訴UIPrinter
只應打印第一頁。我怎樣才能做到這一點?如何在swift 3中使用UIPrintInteractionController.print設置打印頁數?
這裏是我的代碼至極打印所有網頁:
let printer = UIPrinter(url: myURL)
let printerController = UIPrintInteractionController.shared
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "My print job name"
printInfo.outputType = .general
printerController.printInfo = printInfo
let printPageRenderer = MyCustomPageRenderer()
printPageRenderer.addPrintFormatter(myWebView.viewPrintFormatter(), startingAtPageAt: 0)
printerController.printPageRenderer = printPageRenderer
printerController.print(to: printer!) { (printerController, success, error) in
}
代碼應與iOS 9.0兼容。
好,但numberOfPages是隻讀的,所以如何覆蓋? –
您嘗試過showsPageRange = true; ? –
是的,但是使用print方法避免了對話框,所以在這種情況下屬性是無用的,對吧? –