How to access camera flash on UIImagePickerController?

前端 未结 3 2172
醉话见心
醉话见心 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:15

    -(void)flashSelected
    {
    
    if (PickerController.cameraFlashMode == 
    UIImagePickerControllerCameraFlashModeOff) {
    
        if ([UIImagePickerController 
    isFlashAvailableForCameraDevice:UIImagePickerControllerCameraDeviceRear ])
    
        {
            PickerController.cameraFlashMode = 
    UIImagePickerControllerCameraFlashModeOn;
        }
     }
    else
     {
        PickerController.cameraFlashMode = 
    UIImagePickerControllerCameraFlashModeOff;
     }     
    }
    

    alternately..

    -(void)_flashToggle
    {
    if (! [UIImagePickerController isFlashAvailableForCameraDevice:UIImagePickerControllerCameraDeviceRear ])
        return;
    
    if (PickerController.cameraFlashMode == UIImagePickerControllerCameraFlashModeOff)
        PickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
    else
        PickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;  
    }
    

提交回复
热议问题