Show UIImagePickerController from UITableViewController in iPhone

Suppose you need to show UIImagePickerController on cell click of UITableViewController class. Then
1. define UIImagePickerControllerDelegate in the header class.
2. Put following code for the cell index of didSelectRowAtIndexPath method

imgPicker = [[UIImagePickerController alloc] init];
    imgPicker.allowsImageEditing = NO;
    imgPicker.delegate = self; 
    imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imgPicker.navigationBar.tintColor =  self.navigationController.navigationBar.tintColor;
    imgPicker.navigationBar.barStyle =self.navigationController.navigationBar.barStyle; 
    [self.navigationController presentModalViewController:imgPicker animated:YES];
To return from image picker
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
  
 
... Perform operation on selected image ...

 [[picker parentViewController]  dismissModalViewControllerAnimated:YES];
 

}
Hope, it helps.

No comments:

Post a Comment