I’m pushing a number of views:
- the top one is a UITabBarController
- the second one is a UINavigationController with a pushed view
- the third one is a modal box.
Once the close button in the modalbox is pressed I’m trying to revert everything to the default state and change the tabbar index.
[self dismissModalViewControllerAnimated:YES];
[self.navigationController popViewControllerAnimated:NO];
[self.tabBarController setSelectedIndex:3];
This dismisses the modal view but doesn’t do anything else. Any ideas what could be wrong? I read something about a possible ios bug but I don’t know how to work around it.
Neither
UITabBarControllernorUINavigationControlleris a view. Both are subclasses ofUIViewControllerand have a propertyNSArray *viewControllers.If you have an
actualViewcontrolled by anActualViewControllerthat is pushed on top of arootViewcontrolled by aRootViewControllerthat is therootViewControllerfor thenavigationController, and you also have amodalViewcontrolled by aModalViewController, then putin
ModalViewController.m, and putin
ActualViewController.m(from whencemodalViewis pushed, presumably), and putin
RootViewController.m(from whenceactualViewis pushed, presumably).If
modalViewControllerwas never added to thenavigationController, then it doesn’t know that thenavigationControllerexists.If
actualViewControllerwas never added to thetabBarController, then it doesn’t know that thetabBarControllerexists.