Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set front-facing camera in iPhone SDK

I would like to have my app open the camera (presently UIImagePickerController ) front-facing if available. (Iphone SDK).

How can I do that?

like image 392
Olav Avatar asked Sep 08 '10 15:09

Olav


2 Answers

It's right there in the documentation:

picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;

Of course, you'll need to check first if the front camera is actually available. It's also only available starting with iOS 4.0.

like image 79
Ole Begemann Avatar answered Oct 21 '22 03:10

Ole Begemann


Try this method of UIImagePickerController:

 + (BOOL)isCameraDeviceAvailable:(UIImagePickerControllerCameraDevice)cameraDevice

This is a class method and UIImagePickerControllerCameraDevice can take two values:

  - UIImagePickerControllerCameraDeviceRear
  - UIImagePickerControllerCameraDeviceFront
  Example code:

        if([UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceFront ])
        {
        // do something
        }
like image 37
Khushbu Shah Avatar answered Oct 21 '22 05:10

Khushbu Shah