static int i = 0;
- (IBAction)longAction:(UIDoubleTapRecogenizer *)sender {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (i % 2 == 0)
{
if ([device hasTorch])
{
[device lockForConfiguration:nil];
[device setTorchMode: AVCaptureTorchModeOn];
[device unlockForConfiguration];
}
}
else
{
if ([device hasTorch])
{
[device lockForConfiguration:nil];
[device setTorchMode: AVCaptureTorchModeOff];
[device unlockForConfiguration];
}
}
i++;
}
Thesedays, I need to add a function to my iOS project. I need to add a function that we users double tap the screen, the flash light will be lighten up. How to complete it?
The source code can be found as follows: