iOS 扫描证件iOS 13后,VisionKit

2020-12-02  本文已影响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
上一篇 下一篇

猜你喜欢

热点阅读