当在独立的单一视图应用程序中呈现时,以下代码可以处理。
当粘贴到在iPad上运行的应用程序(使用splitview控制器)并从按钮上的UIAlertController操作启动时,它会崩溃(在AppDelegate顶部触发断点 - 线程1:断点1.2)出现打印交互表。我甚至试过在专用的UIViewController中解雇它而没有运气。有什么想法吗?
let pInfo = UIPrintInfo.printInfo()
pInfo.outputType = UIPrintInfoOutputType.general
pInfo.jobName = "Shopping List"
pInfo.orientation = UIPrintInfoOrientation.portrait
let formatter = UIMarkupTextPrintFormatter(markupText: "<html><body>Hellow world!</body></html>")
let printController = UIPrintInteractionController.shared
printController.printInfo = pInfo
printController.showsPaperSelectionForLoadedPapers = true
printController.printFormatter = formatter
printController.delegate = self
printController.present(animated: true, completionHandler: nil)