uiimageviewcontroller ios无法使用相机闪光灯

时间:2017-06-21 12:54:52

标签: ios uiimagepickercontroller

不闪烁任何闪光灯 -

driver.execute_script("javascript:shop\\.orders\\.save()")

1 个答案:

答案 0 :(得分:0)

您可以使用AVFoundation框架(例如:

)访问设备火炬模式,轻松更改设备火炬模式

Swift 3.0

    func toggleTorchMode() {
    if let device = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo), device.hasTorch {
        let isTorchSupported = device.isTorchModeSupported(mode)
        let isTourchAvailable = device.isTorchAvailable
        if isTorchSupported && isTourchAvailable {
            do {
                try device.lockForConfiguration()
                if device.torchMode == AVCaptureTorchMode.on {
                    device.torchMode = AVCaptureTorchMode.off
                }
                else {
                    device.torchMode = AVCaptureTorchMode.on
                }
                device.unlockForConfiguration()
            } catch {
                Globals.printlnDebug("Error in setting the torch mode")
            }
        }
        else if mode == AVCaptureTorchMode.on{

            Globals.showErrorMessage("Torch not available", inViewController: self)
        }
    }
}

<强>目标C

-(void)toggleTorchMode
{
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    if ((device) && (device.hasTorch) && (device.isTorchAvailable)) {
        [device lockForConfiguration:nil];
        if (device.torchMode == AVCaptureTorchModeOn) {
            device.torchMode = AVCaptureTorchModeOff;
        }
        else {
            device.torchMode = AVCaptureTorchModeOn;
        }
    }
    else {
        //ERROR: Device doesn't have tourch
    }
}