How to control the flash light(iOS platform)

来源:互联网 发布:mac pro 贴膜涂层脱落 编辑:程序博客网 时间:2024/05/01 11:58

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:


0 0
原创粉丝点击