Showing
2 changed files
with
10 additions
and
2 deletions
| @@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
| 13 | - Enable usage of printer's settings on Windows [Alban Lecuivre] | 13 | - Enable usage of printer's settings on Windows [Alban Lecuivre] |
| 14 | - Update android projects (mavenCentral, compileSdkVersion 30, gradle:4.1.0) | 14 | - Update android projects (mavenCentral, compileSdkVersion 30, gradle:4.1.0) |
| 15 | - Use syscall(SYS_memfd_create) instead of glibc function memfd_create [Obezyan] | 15 | - Use syscall(SYS_memfd_create) instead of glibc function memfd_create [Obezyan] |
| 16 | +- Fix directPrint issue with iOS 15 | ||
| 16 | 17 | ||
| 17 | ## 5.6.6 | 18 | ## 5.6.6 |
| 18 | 19 |
| @@ -70,12 +70,13 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | @@ -70,12 +70,13 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | ||
| 70 | return | 70 | return |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | + DispatchQueue.main.async { [self] in | ||
| 73 | let controller = UIPrintInteractionController.shared | 74 | let controller = UIPrintInteractionController.shared |
| 74 | controller.delegate = self | 75 | controller.delegate = self |
| 75 | 76 | ||
| 76 | let printInfo = UIPrintInfo.printInfo() | 77 | let printInfo = UIPrintInfo.printInfo() |
| 77 | printInfo.jobName = jobName! | 78 | printInfo.jobName = jobName! |
| 78 | - DispatchQueue.main.async { printInfo.outputType = .general } | 79 | + printInfo.outputType = .general |
| 79 | if orientation != nil { | 80 | if orientation != nil { |
| 80 | printInfo.orientation = orientation! | 81 | printInfo.orientation = orientation! |
| 81 | orientation = nil | 82 | orientation = nil |
| @@ -83,7 +84,6 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | @@ -83,7 +84,6 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | ||
| 83 | controller.printInfo = printInfo | 84 | controller.printInfo = printInfo |
| 84 | controller.printPageRenderer = self | 85 | controller.printPageRenderer = self |
| 85 | 86 | ||
| 86 | - DispatchQueue.main.async { | ||
| 87 | if self.printerName != nil { | 87 | if self.printerName != nil { |
| 88 | let printerURL = URL(string: self.printerName!) | 88 | let printerURL = URL(string: self.printerName!) |
| 89 | 89 | ||
| @@ -93,7 +93,14 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | @@ -93,7 +93,14 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | ||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | let printer = UIPrinter(url: printerURL!) | 95 | let printer = UIPrinter(url: printerURL!) |
| 96 | + printer.contactPrinter { available -> Void in | ||
| 97 | + if !available { | ||
| 98 | + printing.onCompleted(printJob: self, completed: false, error: "Printer not available") | ||
| 99 | + return | ||
| 100 | + } | ||
| 101 | + | ||
| 96 | controller.print(to: printer, completionHandler: self.completionHandler) | 102 | controller.print(to: printer, completionHandler: self.completionHandler) |
| 103 | + } | ||
| 97 | } else { | 104 | } else { |
| 98 | controller.present(animated: true, completionHandler: self.completionHandler) | 105 | controller.present(animated: true, completionHandler: self.completionHandler) |
| 99 | } | 106 | } |
-
Please register or login to post a comment