views:

7198

answers:

3

I'm writing an iPhone app with Cocoa in xcode. I can't find any tutorials or sample code that shows how to take photos with the built in camera. How do I do this? Where can I find good info?

Thanks!

+4  A: 

The UIImagePickerController class lets you take pictures or choose them from the photo library. Specify the source type as UIImagePickerControllerSourceTypeCamera.

See also this question previously asked: http://stackoverflow.com/questions/74113/access-the-camera-with-iphone-sdk

jblocksom
+7  A: 

Use UIImagePickerController. There is a good tutorial on this here.

http://www.zimbio.com/iPhone/articles/1109/Picking+Images+iPhone+SDK+UIImagePickerController

You should set the source type to UIImagePickerControllerSourceTypeCamera or UIImagePickerControllerSourceTypePhotoLibrary. Note that these two types result in very different displays on the screen. You should test both carefully. In particular, if you are nesting the UIImagePickerController inside a UINavigationController, you can end up with multiple navigation bars and other weird effects if you are not careful.

See also this thread

Airsource Ltd
+3  A: 

Hi, I'm trying to perform the task of taking a picture, but triggered by code instead of relying on the touching of the camera button in UIImagePickerController. Can this be done?