Ok I know there are lots of info on this subject however everything I have tried does not work. My setup is this.
App loads View A which is a Tableview with a navigationController. After a delay I present a ModalView B. On view B i have a button that presents another modalView View C above View B. In Modal View C I have a button to Dismiss C. Now when I hit this button I would also like to dissmis Modal View B taking me back to my RootView which is the mentioned tableView view A.
From Modal View C I have a button but can only dismiss C using the below Action this takes me to modal view B: What I would like to do is remove C and B with this button returning me to A if this is possible?
-(IBAction)dismissWebView:(id)sender{
[self dismissModalViewControllerAnimated:YES];
}
I have tried all of these from the above action
[self.parentViewController dismissModalViewControllerAnimated:YES];
[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];
[adsRootView dismissModalViewControllerAnimated:YES];
[self dismissModalViewControllerAnimated:YES];
[self dismissModalViewControllerAnimated:YES];
[self.navigationController dismissModalViewControllerAnimated:YES];
[self.adsRootView dismissModalViewControllerAnimated:YES];
[[[self parentViewController] parentViewController] dismissModalViewControllerAnimated:YES];
[self.navigationController popToRootViewControllerAnimated:NO];
None of which do anything apart from dismissing only Modal view C.
So the easy way is to get to your A controller, which is not parent-child relationship in this case, but a presenting/presented relationship:
[self.presentingViewController.presentingViewController dismiss...]
^C ^B ^A
But, this is not very clean and will get you when you change your controller hierarchy, so I would advice setting a delegate to notify when it's ok to dismiss controllers.