I have a switch that if I activate it, I turn on the camera flash and if you turn off, turn off (default is off)
This is my code:
- (void)viewDidAppear:(BOOL)animated
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO)
return;
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerCameraCaptureModeVideo];
picker.allowsEditing = NO;
picker.showsCameraControls = NO;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
}
- (IBAction) onChangeSwitch:(id)sender
{
switch(interruptor.on){
case YES:
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
break;
case NO:
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
break;
}
}
Looking online, I've seen the code I have is to turn the flash simply and not to start or stop the torch from the iPhone camera.
I've seen it done with the AVCaptureDevice Turn on torch/flash on iPhone # 3367424 I do not know now how could adapt that to my code.
Does anyone know and gives me a hand?
thanks