我试图回UIImage,这是我捕捉到的。打印时,捕获的图像打印成功,但在回调中,图像为零。不知道我在哪里犯错。
以下是框架代码:
public var imageCallBack: ((UIImage) -> ())?
public func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
guard scan.pageCount >= 1 else {
controller.dismiss(animated: true)
return
}
let originalImage = scan.imageOfPage(at: 0)
self.imageView.image = originalImage
let newImage = compressedImage(originalImage)
print("new image::\(newImage.size)")
imageNew = newImage
print("image new", imageNew!)
imageCallBack?(newImage)
print("image call back", imageCallBack?(newImage) as Any)
controller.dismiss(animated: true)
}
@IBAction func saveBtn(_ sender: Any) {
if let img = imageView.image {
imageNew = img
print("image new1", imageNew!)
print("call back",imageCallBack!(imageNew!))
}
self.removeFromParent()
self.view.removeFromSuperview()
}
下面是代码示例项目。在这里,我试图从框架中获取图像:
override func viewDidAppear(_ animated: Bool) {
let vc1 = ScannerViewController()
vc1.imageCallBack = { [weak self] image in
print("result image", image)
}
}
任何帮助,非常感谢.
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。