-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scanner.swift
36 lines (27 loc) · 1 KB
/
Scanner.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import UIKit
import VisionKit
class Scanner: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func touchUpInsideCameraButton( Sender:Any){
configureDocumentView()
}
private func configureDocumentView() {
// guard VNDocumentCameraViewController.isSupported else { return } // silinebilir yaratılan metodun controllera uyumununu kontrol eder
let controller = VNDocumentCameraViewController()
controller.delegate = self
self.present(controller, animated: true)
}
}
extension Scanner: VNDocumentCameraViewControllerDelegate {
func documentCameraViewController( controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
for index in 0 ..< scan.pageCount {
let image = scan.imageOfPage(at: index)
print(image)
// save image
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil)
}
controller.dismiss(animated: true, completion: nil)
}
}