iPhone에서 전면 카메라를 사용하고 후면 조명 LED를 켜야합니다. 어떻게 할 수 있습니까? 이 코드를 사용하여 전면 카메라를 열 수 있습니다iPhone에서 플래시와 전면 카메라를 동시에 켜십시오.
- (void) turnCameraOn {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePicker.showsCameraControls = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Camera unavaliable"
message:@"Unable to find camera on your device."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
alert = nil;
}
}
을하고 나는이 코드에 주도 설정할 수 있습니다
- (void) turnTorchOn: (bool) on {
Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
if (captureDeviceClass != nil) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] && [device hasFlash]){
[device lockForConfiguration:nil];
if (on) {
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
} else {
[device setTorchMode:AVCaptureTorchModeOff];
[device setFlashMode:AVCaptureFlashModeOff];
}
[device unlockForConfiguration];
}
}
}
나는 APP와 전면 카메라를 열 때 LED가 꺼집니다 표시 . 나는 둘 다 동시에 일해야한다.
감사합니다.
여기까지 행운이 있습니까? –
아무것도 :(사과가 그렇게 할 수있는 것 같습니다. 사과 손전등은 다른 모든 손전등 응용 프로그램과 같이 카메라에 액세스하지 마십시오. – rendellhb
@rendellhb : 나는이 기능을 안드로이드에서 원합니다. 가능한지 알고 있습니까? – Basher51