How to know if iPhone camera is ready to take picture?

后端 未结 7 1877
清酒与你
清酒与你 2020-12-05 06:54

When [camera takePicture] is called before the camera is ready, it spits out this message:

UIImagePickerController: ignoring request to take pictu

相关标签:
7条回答
  • 2020-12-05 07:56

    If you are using UIImagePickerController, following is the code for video, similar code implies for image as well.

    UIImagePickerController *picker;
    BOOL cameraIsOn;
    

    Then check for camera device available

    if ([UIImagePickerController isCameraDeviceAvailable:[picker cameraDevice]]) {
                if (cameraIsOn) {
                    NSLog(@"stop camera");
                    [picker stopVideoCapture];
                    cameraIsOn = FALSE;
                }
                else {
                    NSLog(@"start camera");
                    [picker startVideoCapture];
                    self.videoTimer =  [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeValue) userInfo:nil repeats:YES];
                    cameraIsOn = TRUE;
                }
            }
    
    0 讨论(0)
提交回复
热议问题