Disable two modal controllers

I have a navigation controller that represents one modal viewController. From within this modal viewController, I present another modal viewController. All I want is to return from the last modal viewController to the navigationController (root viewController). Something similar to popToRootViewController, but adapted for modalViewControllers;

NavigationController β†’ present Modal ViewController A β†’ present Modal ViewController B

From modal ViewCOntroller B I want to return to navigationCOntroller.

Is it possible?

Appreciate Alex.

+8
objective-c modalviewcontroller
source share
2 answers

The problem is resolved :)

I tried

[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES]; 

and working.

Thanks.

+5
source share

In iOS 5 you need to do

[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES]

Edit: with iOS 6 dismissModalViewControllerAnimated: deprecated.

You need to call

[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{ // Do something on completion}]

+30
source share

All Articles