1

So I have a UINavigationController that pushes a UITableViewController from the rootViewController. From the UITableViewController, I want a UIImagePickerController to be pushed when I click a certain cell. How would I get the navigation controller to display the image picker?

1 Answer 1

2
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {
       UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
       imagePicker.delegate = self;

       [self presentModalViewController:imagePicker animated:YES];
       // don't release imagePicker here
    }

Then define UIPickerControllerDelegate in your tableViewController implementation.

Sign up to request clarification or add additional context in comments.

2 Comments

Note that the first will not work, because UIImagePickerController is itself a UINavigationController and cannot be embedded in another navigation controller. Also, neither of these will work on the iPad. As per the documentation you can only show a UIImagePickerController in a UIPopoverController or as a replacement of the current view.
I think the first should be removed, as it will cause an exception like shezi states, and that can be confusing to users reading this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.