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

Carlos Alberto Silva Neto
Carlos Alberto Silva Neto
2,346 Points

Warning msg

When I cancel the camera:

Warning: Attempt to present <UIImagePickerController: 0x16dcc590> on <TabBarController: 0x16e96a10> while a presentation is in progress!

Code:

  • (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{ [self dismissViewControllerAnimated:NO completion:nil]; [self.tabBarController setSelectedIndex:0]; }

1 Answer

Gareth Borcherds
Gareth Borcherds
9,372 Points

This message is typically caused when you are trying to display a view controller when a view controller is already in the process of being displayed. You see this when you add code to dismiss or add a view controller, but at the same time it's being handled via the storyboard and a segue tied to a button. Try deleting [self dismissViewControllerAnimated:NO completion:nil]; and see if it gives you the error. If it does, replace it and try deleting [self.tabBarController setSelectedIndex:0]; and see if that's the offending code. You might not need either of those statements.