This issue has just appeared with iOS 13 and was not a problem prior. If I am presenting the UIPrintInteractionController
controller with a single image, everything works fine. If I submit with more than one image, the print controller will not be displayed and instead I will get an error that states: Warning: Attempt to dismiss from view controller <UIViewController: 0x7fefcc4e7ab0> while a presentation or dismiss is in progress!
Below is the code in question. So again, if printingItems
contains more than 1 element (which is the entire point of it), the controller won't display and the success
portion of the completion handler will return false
. Was not an issue in iOS 12.This is running on an 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)
}
}
}
I was also facing the same issue with multiple pdf files, so I just merged all the pdfs into one pdf and used
instead of
Its a work around to solve the issue for now. Hope its helps.