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
Demetrius Albuquerque
Python Web Development Techdegree Student 5,071 PointsUIImagePickerController Warning: Attempt to present on UITabBarController while a presentation is in progress!
Im doing the "Build a Self-Destructing Message iPhone App" using XCode 5, iOS 7 and iPhone 5. But when I try to use the imagepickerview, it's does not work well. I see this message on console: Warning: Attempt to present <UIImagePickerController> on <UITabBarController> while a presentation is in progress!
I tried some changes but nothing worked until now, I using that to show the UIImagePickerView
[self presentViewController:self.imagePicker animated:NO completion:nil];
Dismissing on delegate with:
[self dismissViewControllerAnimated:NO completion:nil];
I also tried another codes like:
[self.tabBarController presentViewController:self.imagePicker animated:NO completion:nil];
and
[picker dismissViewControllerAnimated:NO completion:nil];
But I always receive same message.
4 Answers
Keith Klingen
9,031 PointsThis warning appears because of this line in CameraViewController viewWillAppear: [self presentViewController:self.imagePicker animated:NO completion:nil];
Apparently presenting a second view from the first view's viewWillAppear will cause two views to overlap presentations, at least briefly.
I solved this by moving the code to viewDidAppear. Then the problem was it kept re-appearing too often, so you'll have to surround this code with a conditional like so: -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; if(doImagePicker){ doImagePicker = false; [self presentViewController:self.imagePicker animated:NO completion:nil]; } }
BOOL doImagePicker = false; should be set in the .h
doImagePicker = true; will need to be set in imagePickerControllerDidCancel and didFinishPickingMediaWithInfo
Basically, telling the ImagePicker only to run the first time viewDidAppear is called, or after you've previously cancelled the action or chosen an image.
Stone Preston
42,016 Pointsits just a warning. the app still works correctly right?
Jack Solomon
839 PointsI've had that issue heaps of times, but it is never going to really be a problem. If you still want to get rid of it, it's essentially because for a very short period of time there are no views, or two views presented. To fix this, present the view, or dismiss, using completion. i.e:
[self dismissViewControllerAnimated:NO completion:^{ //Code to show view here [self presentViewController:self.imagePicker animated:NO completion:nil]; }];
You might need to modify this a bit (I haven't looked into it properly to fit the self destruct message app).
Fabrizio Rinaldi
5,359 PointsI can't see messages received inside the app, and i didn't change anything inside.
I got the same problem too!