“Hide” the Tab Bar When Pushing a View

后端 未结 3 750
暗喜
暗喜 2021-01-13 02:20

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.

相关标签:
3条回答
  • 2021-01-13 02:43

    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.

    0 讨论(0)
  • 2021-01-13 02:48

    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.

    0 讨论(0)
  • 2021-01-13 02:57

    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];
    }
    
    0 讨论(0)
提交回复
热议问题