Code Block extension ViewController: VNDocumentCameraViewControllerDelegate, UIImagePickerControllerDelegate { func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinish scan: VNDocumentCameraScan) { for pageNumber in 0..<scan.pageCount { let image = scan.imageOfPage(at: pageNumber) print(image) //save hasPhoto = true UIImageWriteToSavedPhotosAlbum(image, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil) //UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) } controller.dismiss(animated: true, completion: nil) }
How I can save scans to user's photo library?
Hello,
I'm not sure what issue you are encountering exactly, but what you have here looks approximately correct.
Things to keep in mind:
I'm not sure what issue you are encountering exactly, but what you have here looks approximately correct.
Things to keep in mind:
You must set your ViewController as the VNDocumentCameraViewControllerDelegate.
You need the "Privacy - Photo Library Additions Usage Description" key in your info.plist (or the "Privacy - Photo Library Usage Description" if you also need read access to the Photo Library).