美文网首页
iOS调起系统照相机时关闭闪关灯

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

作者: 一吻江山 | 来源:发表于2016-08-29 11:39 被阅读400次

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

    无效做法:

    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调起系统照相机时关闭闪关灯

          本文链接:https://www.haomeiwen.com/subject/ktmxettx.html