views:

1600

answers:

3

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!

+3  A: 

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.

Matt Long
+2  A: 

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];
}
Chris Miles
+2  A: 

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.

Warrior