Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Capturing Photo and Video Using UIImagePickerController viewDidLoad and the View Controller Lifecycle

[self.tabBarController setSelectedIndex:0]

When cancel is clicked, the tab image picker disappears, but I am still in the "Camera" tab. I followed the code exactly in CameraViewController.m :

#pragma mark - Image Picker Controller delegate

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { // used to do something after a photo is selected or cancel
    [self dismissViewControllerAnimated:NO completion:nil]; // what happens when view controller is left

    [self.tabBarController setSelectedIndex:0]; // goes to inbox tab (first tab is 0)
}

I tried putting a breakpoint after -(void)... and when i run the app and click cancel, the breakpoint doesn't seem to be doing anything. Any ideas? Thanks

2 Answers

Timothy, here is a full template for the social network application: Click Here.

Sorry, found the problem again. my line telling the imagePicker that cameraviewcontroller is its delegate:

self.imagePicker.delegate = self;

was inside the for loop for seeing whether the camera is available. I do have a question though:

What if there were multiple imagePickers within in a viewcontroller? You would have different names for each obviously, but how would you specify which one to run a certain method in? (Ex.

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker). 

Does this method automatically apply only to the ACTIVE image picker?