I have 2 view controllers presented modally.
A presents B which presents C.
When I dismiss C I would like to dismiss B as well. But I am not sure how to do this:
Dismiss C:
[self dismissModalViewControllerAnimated:YES] //[delegate dismissB] //this doesn't work either when i create a delegate pattern
Now I am left with B. How can I dismiss B from C?
According to the View Controller Programming guide for iPhone OS, this is incorrect when it comes to dismissing modal view controllers you should use delegation. So before presenting your modal view make yourself the delegate and then call the delegate from the modal view controller to dismiss.
Just found out you need to use presentingViewController in iOS 5.
[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES];
A -> B -> C
Running the above code in modal C will take you back to A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With