At some point I need a tabBar controller 开发者_StackOverflow中文版instead of a navigation controller. To achieve this I have released the navigation controller and added a tab bar to the window.
Is the UINavigationcontroller removed from the window hierarchy?
I understand that you want to switch from the navitation controller to a TabBar controller and back, but you are concerned that once removed, you won't be able to get it back.
The obvious solution is not to remove them, but to hide them. The following is a sample for the TabBar controller, it simply animates the y point from 431 to 480 so it gets out of view and back.
- (void) hidetabbar:(BOOL)hiddenTabBar {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in self.uiTabBarController.view.subviews){
if([view isKindOfClass:[UITabBar class]]) {
if (hiddenTabBar) {
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
} else {
if (hiddenTabBar) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
}
[UIView commitAnimations];
}
You can do exactly the same for the navigation controller.
精彩评论