James Sun
James Sun

Reputation: 1461

"Hide" the Tab Bar When Pushing a View

The New York Times iPhone application has a Tab Bar with five tab bar items. When you select the Latest tab, the app shows the title and abstract/summary in a UITableView. When you select an individual story to read, the Tab Bar disappears and is replaced with a header and footer that appears/disappears depending on the state of the app. How does the app "hide" the tab bar?

Thanks!

Upvotes: 5

Views: 7193

Answers (3)

Warrior
Warrior

Reputation: 39374

Implement this piece of code in the class where you want to hide the Tab Bar.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    // Custom initialization
}
self.hidesBottomBarWhenPushed = YES;
return self;
}

All the best.

Upvotes: 10

Chris Miles
Chris Miles

Reputation: 7516

I have a view that needs to optionally (depending on some other state) show the navigation controller toolbar. This is the solution I used to show & hide the toolbar (with animation) when the view appears & disappears via navigation. It sounds like what you might be after.

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // Show the nav controller toolbar if needed
    if (someBool)
        [self.navigationController setToolbarHidden:NO animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    // Hide the nav controller toolbar (if visible)
    [self.navigationController setToolbarHidden:YES animated:animated];
}

Upvotes: 2

Matt Long
Matt Long

Reputation: 24466

The view controller that is being pushed onto the navigation controller stack has its hidesBottomBarWhenPushed parameter set to yes. The code would look something like this in the table view's -didSelectRowAtIndexPath.

NSDictionary *newsItem = [newsItems objectAtIndex:[indexPath row]];
NewsDetailViewController *controller = [[NewsDetailViewController alloc] init];
[controller setHidesBottomBarWhenPushed:YES];
[controller setNewsItem:newsItem];
[[self navigationController] pushViewController:controller animated:YES];
[controller release], controller = nil;

Take a look at the documentation for hidesBottomBarWhenPushed.

p.s. You'll probably get more visibility on this question if you add the tag 'iphone' to it.

Upvotes: 6

Related Questions