source code and explanation are from ios Programming The Big Nerd Ranch Guide 3rd Edition
- add an UIImageView
- in the attributes inspector find the Mode attribute and change it to Aspect Fit (this will resize the image to fit within the bounds of the UIImageView).
- add an UIToolbar, click on single button and change Identifier to Camera.
- ctrl+click and drag the photo icon from toolbar at .h file and create an action
- on .h file conform with the following protocols <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
- put that code on the above action
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
//if our device has a camera, we want to take a picture, otherwise, we
//just pick from photo lirary
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
[self presentViewController:imagePicker animated:YES completion:nil];
to Save the picture we need to implement the