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