Closed j8055 closed 6 years ago
Never mind Figured it out 👍
hi! how is your solution? i meet the same problem
Hi,
What I did was add a target for the toggle torch button like this
qrCodeReaderView?.toggleTorchButton?.addTarget(self, action: #selector(toggleTorch), for: .touchUpInside)
And then used my own method for flash
extension QRCodeScanViewController {
@objc func toggleTorch() {
isTorchLightOn = !isTorchLightOn
guard let device = AVCaptureDevice.default(for: AVMediaType.video)
else {return}
if device.hasTorch {
do {
try device.lockForConfiguration()
if isTorchLightOn == true {
device.torchMode = .on
} else {
device.torchMode = .off
}
device.unlockForConfiguration()
} catch {
print("Torch could not be used")
}
} else {
print("Torch is not available")
}
}
}
Hi, I noticed that the flash wasn't working when I used the scan in preview from the example