这个问题刚刚出现在 iOS 13 中,之前不是问题。如果我向UIPrintInteractionController
控制器展示单个图像,则一切正常。如果我提交了多个图像,则不会显示打印控制器,而是会收到一条错误消息:Warning: Attempt to dismiss from view controller <UIViewController: 0x7fefcc4e7ab0> while a presentation or dismiss is in progress!
下面是有问题的代码。同样,如果printingItems
包含超过 1 个元素(这是它的全部点),控制器将不会显示并且success
完成处理程序的部分将返回false
。在 iOS 12 中不是问题。这是在 iPad 上运行的。
private func print(finalPageImages:[UIImage]) {
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "job name"
printInfo.outputType = .general
printInfo.duplex = .none
printInfo.orientation = .landscape
let printController = UIPrintInteractionController.shared
printController.showsNumberOfCopies = false
printController.printInfo = printInfo
printController.printingItems = finalPageImages
printController.present(from: self.printButton, animated: true) { (controller, success, error) in
guard error == nil else {
Utilities.displayAlert(title: "Print Error", msg: error!.localizedDescription, controller: self)
return
}
if success {
Utilities.displayAlert(title: "Print Status", msg: "Your Shelf Talkers are printing.", controller: self, completion: { (action) in
})
} else {
Utilities.displayAlert(title: "Print Error", msg: "There was a problem with this print job. Please try again.", controller: self)
}
}
}