开发者

Set front-facing camera in iPhone SDK

I would like to have my app open the camera (present开发者_如何学JAVAly UIImagePickerController ) front-facing if available. (Iphone SDK).

How can I do that?


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.


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
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜