Hide the button when the tab bar controller is added to the navigation controller

I have a navigation controller (navC), and I have a view controller (ViewC), which is a view derived from the root controller. I have a hidden button for viewing with code:

[[self navigationItem] setHidesBackButton:YES]; 

After ViewC, I clicked on the tab bar controller (tabbarC). In the view controller associated with the first tab in tabbarC, I tried to hide 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 anyone help me hide the back button for all views in tabbarC.

+4
source share
3 answers

In your first view, which will appear when you click on your tabbarview controller, set this

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

In the DidLoad view of the ViewC, do the following:

 [self.navigationController.navigationItem setHidesBackButton:YES]; 

The selected view type of the ViewWillAppear controller is also selected.

 [self.navigationController.navigationItem setHidesBackButton:YES]; 
0
source

In your opinion, just write this line .. it will hide the button. checked

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

Source: https://habr.com/ru/post/1435433/


All Articles