
打开和关闭割炬(手电筒)时,使用该精确方法获取设备.在这种情况下,行:
@H_404_15@let devicediscoverySession = AVCaptureDevice.discoverySession(deviceTypes: [.builtInDualCamera],position: .back)guard let device = devicediscoverySession.devices.first例:
@H_404_15@func toggletorch() { let devicediscoverySession = AVCaptureDevice.discoverySession(deviceTypes: [.builtInDualCamera],position: .back) guard let device = devicediscoverySession.devices.first else {return} if device.hasTorch { do { try device.lockForConfiguration() let on = device.isTorchActive if on != true && device.isTorchModeSupported(.on) { try device.setTorchModeOn(level: 1.0) } else if device.isTorchModeSupported(.off){ device.torchMode = .off } else { print("Torch mode is not supported") } device.unlockForConfiguration() } catch { print("Torch Could not be used") } } else { print("Torch is not available") }}我意识到toggletorch函数中的某些代码可能是多余的,但我要离开它了.希望这可以帮助.
总结以上是内存溢出为你收集整理的ios – 当火炬打开时,AVCaptureSession冻结全部内容,希望文章能够帮你解决ios – 当火炬打开时,AVCaptureSession冻结所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)