Assuming I present a modal view B based on A, and then present a modal view C based on B.
Is there any way to dismiss both B and C and go back to A directly?
Assuming I present a modal view B based on A, and then present a modal view C based on B.
Is there any way to dismiss both B and C and go back to A directly?
Assuming you use storyboards in XCode4.5, you can use the new unwind segue. Implement
-(IBAction)back:(UIStoryboardSegue*)segue
in A. (You can leave the function definition empty.) Then in the controller of C right click on the new exit icon and connect the new entry to the control that shall initiate the unwinding.
yes, i have some solution, probably it is a little bit dirty but you can work around
UIViewController* vc = self;
while (vc) {
UIViewController* temp = vc.presentingViewController;
if (!temp.presentedViewController) {
[vc dismissViewControllerAnimated:YES completion:^{}];
break;
}
vc = temp;
}
you can call this from any of model controllers in your stack, all of them will be dismissed. We are just searching for the second one and then dismiss it.
Yes, you can call [B dismissModalViewControllerAnimated:YES];
this will dismiss B. of course, if C is presented from B, it will be dismissed too.
And, here is relative question, it contains complete answer. iPhone - dismiss multiple ViewControllers