AVCapturePhotoOutput captures image before flash goes off

337 views Asked by At

I am building a camera app using AVCapturePhotoOutput on iOS 11. Below I have set the flashMode to on using AVCapturePhotoSettings and return the captured image to the view. The flash and photo capture both successfully run, but the photo is captured before the flash comes on. Is there a way to sync the flash and photo capture to where the capture happens when the flash lights?

Below is my code:

-(void)CapturePhoto
{
    photoSettings = [AVCapturePhotoSettings photoSettings];
    photoSettings.flashMode = AVCaptureFlashModeOn;
    [photoOutput capturePhotoWithSettings:photoSettings delegate:self];
}
-(void)captureOutput:(AVCapturePhotoOutput *) photoOutput
       didFinishProcessingPhoto:(AVCapturePhoto *) photo
       error:(NSError *)error
{
    if (error)
    {
        NSLog(@"error : %@", error.localizedDescription);
    }
    NSData *data = photo.fileDataRepresentation;
    UIImage *image = [UIImage imageWithData:data];
    NSString* snapshotResponse = @"image has been outputted!";
    NSLog(@"%@", snapshotResponse);
 }
0

There are 0 answers