1

My Project has the following structure: Tab Bar -> Nav Bar -> Controller 1 -> Controller 2 -> Controller 3.

All segues except the last one are push segues, while the last one is a modal segue.

After submitting a request, I am trying to dismiss the modal request, followed by popping to Controller 1.

I have tried some variations of the following without any luck. My guess is that 'presentingViewController' is already null.

[self dismissViewControllerAnimated:NO completion:^
{ 
   [self.presentingViewController.navigationController popToRootViewControllerAnimated:YES];
}];

Any ideas how I can achieve this?

Thanks!

Iain Samuel McLean Elder
  • 19,791
  • 12
  • 64
  • 80
  • Have you tried an unwind segue? http://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-to-use-them – rdprado Feb 05 '14 at 11:04

1 Answers1

1

A view controller should not dismiss itself. From the View Controller Programming Guide for iOS: "When it comes time to dismiss a presented view controller, the preferred approach is to let the presenting view controller dismiss it."
The modal view controller should have the presenting view controller as its delegate. In this way it can inform the presenting view controller that it is ready to be dismissed. The presenting view controller will dismiss the modal view controller, and then it can popToRootViewController.

user3071962
  • 320
  • 3
  • 8