It looks like you want to use a combination of UIActionSheet and UIImagePickerController. This code shows a popup that allows the user to select a photo or select an existing one, then the UIImagePickerController will pretty much do the rest:
- (IBAction)handleUploadPhotoTouch:(id)sender { mediaPicker = [[UIImagePickerController alloc] init]; [mediaPicker setDelegate:self]; mediaPicker.allowsEditing = YES; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take photo", @"Choose Existing", nil]; [actionSheet showInView:self.view]; } else { mediaPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentModalViewController:mediaPicker animated:YES]; } } - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { mediaPicker.sourceType = UIImagePickerControllerSourceTypeCamera; } else if (buttonIndex == 1) { mediaPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } [self presentModalViewController:mediaPicker animated:YES]; [actionSheet release]; }
NOTE. It is assumed that you have a member variable "mediaPicker" that contains a reference to UIImagePickerController
source share