By displaying the VNDocumentCameraViewController on iOS it automatically stores previous scans. This can be problematic for users who don't realize they are adding already scanned documents to their current scan.
Looking at the official VisionKit documentation I don't see any reference to how to do so that when doing viewController?.present(scannerController, animated: true)
.
How can I achieve that?
The solution to this problem is to create one instance at a time.
In my case, I had the following defined at the beginning of the class:
let scannerController: VNDocumentCameraViewController = VNDocumentCameraViewController()
So every time I wanted to display it I just called
viewController?.present(scannerController, animated: true)
.The solution is to instantiate VNDocumentCameraViewController every time you want to use it, this way a "new" view is started with no traces of previous scans: