Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide parent tabbar when pushing controller in navigationController

I have an application with a tab bar controller and each view contains a navigation controller. My MainWindow looks as follows: Image here http://www.freeimagehosting.net/image.php?7bc867a594.png

Everything works fine as it is but I noticed a problem when pushing a details view to the navigation controller. In the didSelectRowAtIndexPath for a tableviewcontroller that belongs to the tab bar controller (the one called Latest in the image) I am doing this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {     ArticleViewController *articleController = [[ArticleViewController alloc] initWithNibName:@"ArticleView" bundle:nil];      [self.navigationController pushViewController:articleController animated:YES];      [articleController release];     articleController = nil; } 

The ArticleViewController has its own tabbar because it needs to display different things. The problem is that when I push the ArticleViewController into the navigationController I see both tabbars at the bottom of the view. Is there any way I can solve this problem?

Thanks in advance

like image 244
Yannis Avatar asked Jun 01 '10 06:06

Yannis


People also ask

How do I hide tabBar when pushing?

You can do this in storyboard now: Select the UIViewController in your storyboard. Select the checkbox Hide Bottom Bar on Push.

How do I hide a tabBar in Swift?

Simply, Go to ViewController (in StoryBoard) -> Attribute inspector -> Under 'View Controller' section select 'Hide Bottom Bar on Push' checkbox. This works like a charm.

How do I hide the bottom tabBar in Swift?

If you don't want that behavior, you should set hidesBottomBarWhenPushed to true where applicable. This will hide the tab bar along with any toolbars you had showing, but only when a view controller is pushed onto the navigation stack. This allows you to show the tab bar at first, then hide it when you need more room.

What is tabBar controller?

A tab bar controller keeps a reference to its child view controllers. We can access that array through the viewControllers property of the tab bar controller. That's part of the solution. In the viewDidLoad() method of the TabBarController class, we invoke a helper method, setupChildViewControllers() .


1 Answers

After spending hours and posting a question here I found that the solution to this problem is adding the following line after the instantiation of ArticleController.

articleController.hidesBottomBarWhenPushed = YES; 
like image 180
Yannis Avatar answered Sep 29 '22 11:09

Yannis