我有一個開關,如果我激活它,我打開相機閃光燈,如果關閉,關閉(默認爲關閉)問題與相機閃光燈iphone
這是我的代碼:
- (void)viewDidAppear:(BOOL)animated
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO)
return;
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerCameraCaptureModeVideo];
picker.allowsEditing = NO;
picker.showsCameraControls = NO;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
}
- (IBAction) onChangeSwitch:(id)sender
{
switch(interruptor.on){
case YES:
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
break;
case NO:
picker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
break;
}
}
在線看,我已經看到我的代碼是簡單地轉動閃光燈,而不是從iPhone攝像頭啓動或停止手電筒。
我已經看到它用AVCaptureDevice完成Turn on torch/flash on iPhone#3367424我不知道現在怎麼能適應我的代碼。
有誰知道並給我一隻手?
感謝
非常感謝。 我會嘗試看看我是否有運氣,但我認爲如果我有選擇器,我不能與AvCaputre混合...看看我是否有運氣。 非常感謝你。 – jekeyeke