Can't use AVCaptureDevice with a flash

后端 未结 2 1326
说谎
说谎 2021-01-21 18:26

I am having difficult times, for something which I think ought to be simple. I just want to light the flash when taking a picture in my iOS app. And all I tried failed or works

2条回答
  •  甜味超标
    2021-01-21 19:02

    I noticed, configuring the AVCaptureDevice, while the AVCaptureSession contained an AVCaptureDeviceInput reference caused this error. My solution was: before configuring an AVCaptureDevice object, remove the AVCaptureDeviceInput reference in the AVCaptureSession and read it when completed. I would no longer get the error with this approach. Example:

    self.input = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:&error];
    

    . .

    [self.session removeInput:self.input];
    if ([device lockForConfiguration:NULL]) {
       device.focusMode = AVCaptureFocusModeContinuousAutoFocus;
       [device unlockForConfiguration];
    }
    [self.session addInput:self.input];
    

提交回复
热议问题