How to access camera flash on UIImagePickerController?

前端 未结 3 2174
醉话见心
醉话见心 2021-02-09 17:43

I would like to know how to switch on the camera flash on the iPhone 4 with UIImagePickerController.

if ([UIImagePickerController isSourceTypeAvailable:UIImagePi         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-09 18:18

    // not all devices have two cameras or a flash so just check here
        if ( [UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceRear] ) {
            imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
            if ( [UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceFront] ) {
                cameraSelectionButton.alpha = 1.0;
                showCameraSelection = YES;
            }
        } else {
            imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
        }
    
        // flash mode on
          if ([UIImagePickerController isFlashAvailableForCameraDevice:imagePicker.cameraDevice] )
           {
                imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
                flashModeButton.alpha = 1.0;
                showFlashMode = YES;
            }
    

提交回复
热议问题