我有一个问题:我想知道打印作业的状态。我正在打印一个临时存储在云驱动器中的 PDF 文件。我想在打印作业完成后删除该文件。我怎样才能 swift 意识到这一点? 这是我的代码片段:
// 1
let printController = UIPrintInteractionController.sharedPrintController()
// 2
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = UIPrintInfoOutputType.General
printController.showsNumberOfCopies = false
printController.showsPageRange = false
printInfo.jobName = "PDF ID: " + pdfObjectID
printController.printInfo = printInfo
// 3
//let formatter = UIMarkupTextPrintFormatter(markupText: "Test")
let formatter = pdf.viewPrintFormatter()
formatter.contentInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
printController.printFormatter = formatter
// show PrintController
printController.presentAnimated(true, completionHandler: nil)
您有什么建议吗? 谢谢:)
最佳答案
我自己没有测试过,但是根据文档,
你可以传递 UIPrintInteractionCompletionHandler
作为 completionHandler:
参数:
When a print job concludes, you can reset any state set up for printing and do related housekeeping tasks.
一个简单的例子:
printController.presentAnimated(true) { (controller, success, error) -> Void in
if success {
// Printed successfully
// Remove file here ...
} else {
// Printing failed, report error ...
}
}
关于ios - 在 Swift 中获取 UIPrintInteractionController 的作业状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34495493/