【发布时间】:2018-09-18 11:32:58
【问题描述】:
我尝试在自定义相机应用程序中为相机设置闪光灯开/关,我正在尝试设置,但相机在 iPhone 6 的前置摄像头模式下打开闪光灯时不断崩溃。感谢任何帮助。谢谢。
if ((currentCamera?.hasFlash)!) {
do {
_ = try currentCamera?.lockForConfiguration()
} catch {
print("aaaa")
}
if (currentCamera?.isTorchActive)! {
sender.setImage(UIImage(named: "flashOff"), for: .normal)
currentCamera?.torchMode = AVCaptureDevice.TorchMode.off
} else {
// sets the torch intensity to 100%
do {
sender.setImage(UIImage(named: "flash"), for: .normal)
_ = try currentCamera?.setTorchModeOn(level: 1.0)
} catch {
print("bbb")
}
// avDevice.setTorchModeOnWithLevel(1.0, error: nil)
}
// unlock your device
currentCamera?.unlockForConfiguration()
}
【问题讨论】:
标签: ios avfoundation swift4 avcapturedevice