美文网首页
iOS 扫描证件iOS 13后,VisionKit

iOS 扫描证件iOS 13后,VisionKit

作者: 移动的键盘 | 来源:发表于2020-12-02 18:27 被阅读0次
import UIKit
import VisionKit

@available(iOS 13.0, *)
@objc public class ShgScanCardImage: UIViewController ,VNDocumentCameraViewControllerDelegate{

@objc public func scan() {
    if !VNDocumentCameraViewController.isSupported {
        return
    }
    let docVC = VNDocumentCameraViewController.init()
    docVC.delegate = self
    self.present(docVC, animated: true, completion: nil)
}

public func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
    controller.dismiss(animated: true, completion: nil)
    let image = scan.imageOfPage(at: 0)
    print(image)
}
public func documentCameraViewControllerDidCancel(_ controller: VNDocumentCameraViewController) {
    controller.dismiss(animated: true, completion: nil)
}
public func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFailWithError error: Error) {
    controller.dismiss(animated: true, completion: nil)
}
}
WechatIMG133.jpeg

相关文章

网友评论

      本文标题:iOS 扫描证件iOS 13后,VisionKit

      本文链接:https://www.haomeiwen.com/subject/zwyuwktx.html