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 Diary App Using Core Data Inserting and Saving Data UI for Inserting Diary Entries

Daniel Haugstvedt
Daniel Haugstvedt
4,655 Points

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; does nothing

I have tried google and it suggest running it on the navigationController. There are also some suggestions on running it on the self instead of the presenting view controller. I have tried all four combinations without any luck. The viewDidDisappear:(BOOL)animated method is newer called (I added a NSLog in it to check).

  • (void)dismissSelf { NSLog(@"dismiss is running"); //[self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil]; //[self.navigationController dismissViewControllerAnimated:YES completion:nil]; //[self dismissViewControllerAnimated:YES completion:nil]; [self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; }

3 Answers

Muhammad Arafat
Muhammad Arafat
5,677 Points

Using [self.dismissViewControllerAnimated:YES completion:nil]; should be enough if by self you mean the view controller that was presented modally; which also must be the one implementing viewDidDisappear method.

Daniel Haugstvedt
Daniel Haugstvedt
4,655 Points

And there it was, I simply forgot to make the segue modal. Thanks for sorting it out so quickly.

Anthony Martinez
Anthony Martinez
13,111 Points

What is the solution now that modal segues are deprecated? Facing the same issue.