Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I implement "Choose Existing Photo" in my app like in default iphone phonebook?

I want to develop an app which has functionality same as iphone phonebook capturing image and choosing iamge,

what should I to use for doing such

I have made an UIImageView and a button for UIActionSheet,

now I want to perform "Take Photo" and "Choose Existing Photo" options in my app

help me out, I do appreciate

thanks in advance ....

like image 985
Chatar Veer Suthar Avatar asked Mar 04 '11 09:03

Chatar Veer Suthar


1 Answers

Hey @Veer you need to use UIImagePickerController

check out the documentation http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html and check out this link

http://iphone.zcentric.com/2008/08/28/using-a-uiimagepickercontroller/

It has sample examples about the same.

Edit you can use these methods to get the image in you UIImageView object

- (void)selectPhotos
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    picker.delegate = self;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

- (void)imagePickerController:(UIImagePickerController *)picker
        didFinishPickingImage:(UIImage *)image
                  editingInfo:(NSDictionary *)editingInfo
{
    imageView.image = image;
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
like image 133
Robin Avatar answered Nov 19 '22 07:11

Robin