I have a switch that, if I activate it, turns on the camera flash, and if you turn it off, turn it off (off by default)
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; } }
In online mode, I saw that the code I have is just to turn on the flash and not start or stop the torch from the iPhone camera.
I saw this with AVCaptureDevice Enable Torch / Flash on iPhone # 3367424 Now I donβt know how to adapt this to my code.
Does anyone know and give me a hand?
thanks
source share