Use Camera And Photo Library In iPhone

The iPhone has  a built-in camera and nifty application called photos to help you to manage all those awesome pictures you’ve taken . Your programs can use the built-in camera to take pictures and your your program can also allow the user to select picture from among the photos already on the iPhone. The both camera and image library are made available to your application by way of an image picker.

Step 1: Create a new project in Xcode using the view base application and naming the application.

Step 2:Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Single click ViewController.h file and add UIButton, UIImage ,IBAction also. Make the following changes into the file.




Step 4: Double click .xib file, open it to the Interface Builder. Drag two Round Rect button from the library and place it bottom of the view window. Give it a title of Camera and Library. Next drag image view from the library, and place it above the buttons. Now connect the File’s Owner icon to the image view and select imageView. Single click camera button and bring up connection inspector . Drag Touch Up Inside event to File’s Owner, and select the getCameraPicture: action. Next select Library button and bring up connection inspector . Drag Touch Up Inside event to File’s Owner, and select the selectExitingPicture: action. Now Save your .xib file and go back to the  Xcode.

Step 5: Single click your ViewController.m file . Add two methods and two delegate methods. Make the following changes.




Step 6: Now compile your application run into the simulator. But you do not have the option to take a new photo. If you have the opportunity to run the on a real device, go ahead and try it.

Figure 1: This is the Library view.

You can downloaded SourceCode from here Camera

Leave a Comment:

Learning iPhone Developing in a systematic way » Blog Archive says February 26, 2010

[…] Use Camera and photo Library in iPhone […]

Jack says April 25, 2010

how would i make it so the photo libary shows up in a splitview in the iPad?

Web Design Macclesfield says July 30, 2012

Brilliantly simple, for both taking and choosing existing pictures.

Thank you.


Asra says September 4, 2012

how can i add camera to take my picture with mask view?? and how can i display a camera with a circle mask to take a picture ?how can i get a window displaying the date of apicture is taken ?? how can buld a scrollbar to change the pictures?? i want this program URGENT…Plz can u help me sending this program with complete code with out using storyboard…..THIS IS very helpfull to me..within 20 hours….i want this program

Asra firdose says September 5, 2012

i want a program on to opens up and defaults to your stick actor figure.

A button camera. When you press camera it allows you to take a picture of yourself with a mask view. In the camera window a circle mask would be displayed and would allow me to only take a picture of what is seen in the circle. i want to take the picture and save it.Left or right scroll on the head only would allow you to switch between the head pictures that i have taken.Touching the head would open up a simple window that would show when the picture was taken and give you the option of if i want to delete it.plz send me this xcode program on iphone with full detail code with connections without using storyboard bcoz i don’t have story board in my xcode..i want this very urgent..with in 10 hours….plzzzz..

Asra firdose says September 5, 2012

i like ur tutorial programs very much ….bcoz they are in detailed always…thanks.!!!

Add Your Reply