iOS调起系统照相机时关闭闪关灯

收到一个变态的需求:调起系统照相机,默认闪关灯关闭

无效做法:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;//没有作用

[self presentViewController:imagePicker animated:YES completion:nil];

有效做法:UIImagePickerController.delegate的代理方法

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
        imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
        imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
    }
}

你可能感兴趣的:(iOS调起系统照相机时关闭闪关灯)