[ADD] stopScanningWhenCodeIsFound property #41
This commit is contained in:
parent
fe54455e66
commit
cc6f25bb37
|
@ -4,6 +4,7 @@
|
||||||
Released on 2016-01-24.
|
Released on 2016-01-24.
|
||||||
|
|
||||||
- [REFACTORING] Rename `completionBlock` of `QRCodeReader` to `codeDidFoundBlock`.
|
- [REFACTORING] Rename `completionBlock` of `QRCodeReader` to `codeDidFoundBlock`.
|
||||||
|
- [ADD] `stopScanningWhenCodeIsFound` flag to stop the scanner when a code is found.
|
||||||
|
|
||||||
## [Version 5.3.1](https://github.com/yannickl/QRCodeReader.swift/releases/tag/5.3.1)
|
## [Version 5.3.1](https://github.com/yannickl/QRCodeReader.swift/releases/tag/5.3.1)
|
||||||
Released on 2016-01-12.
|
Released on 2016-01-12.
|
||||||
|
|
|
@ -67,7 +67,8 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat
|
||||||
|
|
||||||
// MARK: - Managing the Code Discovery
|
// MARK: - Managing the Code Discovery
|
||||||
|
|
||||||
//public var stopScanningWhenCodeIsFound: Bool = true
|
/// Flag to know whether the scanner should stop scanning when a code is found.
|
||||||
|
public var stopScanningWhenCodeIsFound: Bool = true
|
||||||
|
|
||||||
/// Block is executing when a QRCode or when the user did stopped the scan.
|
/// Block is executing when a QRCode or when the user did stopped the scan.
|
||||||
public var codeDidFoundBlock: (QRCodeReaderResult -> Void)?
|
public var codeDidFoundBlock: (QRCodeReaderResult -> Void)?
|
||||||
|
@ -126,7 +127,11 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat
|
||||||
|
|
||||||
// MARK: - Controlling Reader
|
// MARK: - Controlling Reader
|
||||||
|
|
||||||
/// Starts scanning the codes.
|
/**
|
||||||
|
Starts scanning the codes.
|
||||||
|
|
||||||
|
*Notes: if `stopScanningWhenCodeIsFound` is sets to true (default behaviour), each time the scanner found a code it calls the `stopScanning` method.*
|
||||||
|
*/
|
||||||
public func startScanning() {
|
public func startScanning() {
|
||||||
if !session.running {
|
if !session.running {
|
||||||
session.startRunning()
|
session.startRunning()
|
||||||
|
@ -271,7 +276,9 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat
|
||||||
for current in metadataObjects {
|
for current in metadataObjects {
|
||||||
if let _readableCodeObject = current as? AVMetadataMachineReadableCodeObject {
|
if let _readableCodeObject = current as? AVMetadataMachineReadableCodeObject {
|
||||||
if metadataObjectTypes.contains(_readableCodeObject.type) {
|
if metadataObjectTypes.contains(_readableCodeObject.type) {
|
||||||
|
if stopScanningWhenCodeIsFound {
|
||||||
stopScanning()
|
stopScanning()
|
||||||
|
}
|
||||||
|
|
||||||
let scannedResult = QRCodeReaderResult(value: _readableCodeObject.stringValue, metadataType:_readableCodeObject.type)
|
let scannedResult = QRCodeReaderResult(value: _readableCodeObject.stringValue, metadataType:_readableCodeObject.type)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue