간한하게 앱에 플레쉬 기능을 넣고 싶으면 아래 코드를..
제스처에 스와잎 좌우 넣고 호출.
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];
}
'iDev' 카테고리의 다른 글
python으로 간단 웹서버 만들기 (0) | 2012.06.16 |
---|---|
iOS Dev Tip code로 화면 밝기 조절 (0) | 2012.06.10 |
한글 시계 for iOS + 주의점 (0) | 2012.06.10 |
cocos2d에서 implicit declaration of 'glColor4ub' is invalid in c99 해결방법 (0) | 2012.06.08 |
소스코드 복사 후 컴파일 시 Apple Mach-O Linker (Id) Error 해결방법 (5) | 2012.06.08 |