大佬教程收集整理的这篇文章主要介绍了ios – 当火炬打开时,AVCaptureSession冻结,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
let captureSession = AVCaptureSession() let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviCETypes: [.builTinDualCamera],mediaType: AVMediaType.video,position: .BACk) guard let captureDevice = deviceDiscoverySession.devices.first else { print("Couldn't get a camera") return } do { let input = try AVCaptureDeviceInput(device: captureDevicE) captureSession!.addInput(input) } catch { print(error) return }
打开和关闭割炬(手电筒)时,使用该精确方法获取设备.在这种情况下,行:
let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviCETypes: [.builTinDualCamera],position: .BACk) guard let device = deviceDiscoverySession.devices.first
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") } }
以上是大佬教程为你收集整理的ios – 当火炬打开时,AVCaptureSession冻结全部内容,希望文章能够帮你解决ios – 当火炬打开时,AVCaptureSession冻结所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。