I need to dismiss the two modal view controllers, I know how to pop two or more view controllers
UINavigationController* navController = self.navigat
I use the following utility static method to simulate popToRootViewController for a stack of modals:
// Util.m
+ (void)popModalsToRootFrom:(UIViewController*)aVc {
if(aVc.parentViewController == nil) {
return;
}
else {
[Util popModalsToRootFrom:aVc.parentViewController]; // recursive call to this method
[aVc.parentViewController dismissModalViewControllerAnimated:NO];
}
}
You use it like this:
[Util popModalsToRootFrom:aViewController];
If you want something more advanced, you could do this:
+ (void)popModalsFrom:(UIViewController*)aVc popCount:(int)count {
if(aVc.parentViewController == nil || count == 0) {
return;
}
else {
[Util popModalsFrom:aVc.parentViewController popCount:count-1]; // recursive call to this method
[aVc.parentViewController dismissModalViewControllerAnimated:NO];
}
}
Then pass the number of modals to pop, or just -1 to pop all the way to the root.