According to the documentation dismissViewControllerAnimated:completion:
will allow you to dismiss an entire stack of view controllers by merely dismissing the controller on the bottom of the stack. When I try this, only the top controller is being dismissed.
For example, consider the figure below where controller A and B have both been presented modally. If I dismiss A then both A and B should be dismissed, but only B is being dismissed!
Below is the action that is trigged when the user click on B's button. The root view controller dismisses A (its presented controller), but only B is dismissed!!
- (IBAction)dissmissAandB:(id)sender {
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
ViewController *rootViewController =
(ViewController *) appDelegate.window.rootViewController;
[rootViewController.controllerA dismissViewControllerAnimated:YES completion:^{}];Below
}
The root view controller's controllerA
property is set when the first segue is prepared (i.e., when A is presented). Any ideas why this is not working as advertised?