简体   繁体   中英

hide back button when tab bar controller is added in navigation controller

I have a navigation controller (navC) and I have a view controller (ViewC) which is a view pushed from root controller. I have hidden back button for ViewC with code:

[[self navigationItem] setHidesBackButton:YES];

I have pushed tab bar controller (tabbarC) after ViewC . In the view controller associated with the first tab in tabbarC I have tried hiding the back button with the code:

 [[[self tabBarController] navigationItem] setHidesBackButton:YES];

But the back button is still visible When i click it; it disappears... can any one help me hiding the back button for all the views in the tabbarC.

In your first view that will appear when you push to your tabbarviewcontroller set this

-(void)viewWillAppear:(BOOL)animated{
      [super viewWillAppear:animated];
      self.tabBarController.navigationItem.hidesBackButton=YES;
}

In viewDidLoad of ViewC do this:

[self.navigationController.navigationItem setHidesBackButton:YES];

Also tab selected view controller's viewWillAppear method

[self.navigationController.navigationItem setHidesBackButton:YES];

In your view just write this line..it will hide back button .. tested

-(void)viewWillAppear:(BOOL)animated
{
    [self.navigationItem setHidesBackButton:YES];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM