In iOS 4, if you want to dismiss two nested modal view controllers, the following code works:
[[[[self parentViewController] parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];
However in iOS 5 this method no longer works. Does anybody know how to achieve this result in iOS 5?
I have an app that closes nested modal view controllers through NSNotificationCenter. The notification is received by the VC that I want to navigate back to and all the VC’s in between are gone.
In the deeper VC…
In the VC I would like to go back to
This works on iOS 5 device with a project deployed for 4.0+
I hope it helps. If you use this, it will scale to support more VC’s in between your current VC and the one you want to dismiss to, without changing this code