간한하게 앱에 플레쉬 기능을 넣고 싶으면 아래 코드를..

제스처에 스와잎 좌우 넣고 호출. 


UISwipeGestureRecognizer *swipeRecognizer;

        

swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(torchOn:)];

swipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;

        [self.view addGestureRecognizer:swipeRecognizer];

        

swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(torchOff:)];

swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;

        [self.view addGestureRecognizer:swipeRecognizer];



- (void)torchOn:(id)sender{

    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    [device lockForConfiguration:nil];

    [device setTorchMode:AVCaptureTorchModeOn];

    [device unlockForConfiguration];

}


- (void)torchOff:(id)sender{

    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    [device lockForConfiguration:nil];

    [device setTorchMode:AVCaptureTorchModeOff];

    [device unlockForConfiguration];

}


Posted by KraZYeom

댓글을 달아 주세요