1

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);
 }
  • Try changing `photoSettings = [AVCapturePhotoSettings photoSettings];` to `AVCapturePhotoSettings* photoSettings = [AVCapturePhotoSettings new];` – matt May 26 '18 at 18:44
  • Unfortunately, I get the same result. – Harry Kennedy May 27 '18 at 17:26
  • That's a pity because what you're doing looks to me like what you're supposed to do, so that it should work as you expect. There might be something wrong with what you're doing, but it doesn't seem to be in the code you showed. Perhaps you could show more about how `photoOutput` is configured and how the session is configured and set running? – matt May 27 '18 at 17:28

0 Answers0