I have used vision kit for document scanning. I'm able to scan and save the documents, but the old scanned images are shown on the bottom left corner of the screen after coming back to this screen after dismissal. How to clear the scan array after dismissal?
Code:
let vc = VNDocumentCameraViewController()
override func viewDidLoad() {
super.viewDidLoad()
vc.delegate = self
}
//Save button action in document VC
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
print("Found \(scan.pageCount)")
var imgArray: Array<UIImage> = []
for i in 0 ..< scan.pageCount {
let image = scan.imageOfPage(at: i)
imgArray.append(image)
}
dismiss(animated: true) {
self.getFileName(img: imgArray)
}
}
Seems, you keep link to instance of VNDocumentCameraViewController in
vc
constant of your view controller object. And when you show it second time, the same instance is reused.Try create and present it like this: