iPhone – Disable BackButton when pushing a navigation controller via a tab

I have a navigation controller. I create a tab bar controller and add 3 subviews. This way I can navigate back to the root view controller.

< p>The problem is because of the navigation controller in my tab bar format, I cannot disable the back button.

If only one view controller is pushed to the navigation controller, I can disable the back button, but when I When pushing the tab bar controller to the navigation controller, the back button is not disabled. I want to disable it and add my own custom button.

You need to set the navigation item on the tabBarController, not the view controller. Therefore, if you want to disable the back button from the view controller in the tabBarController inside the navigationController, you can use the following Code:

self.tabBarController.navigationItem.hidesBackButton = NO;

I have a navigation controller . I create a tab bar controller and add 3 subviews. This way I can navigate back to the root view controller.

The problem is because of my tab bar formatted navigation controller, I can’t Disable the back button.

If only one view controller is pushed to the navigation controller, I can disable the back button, but when I push the tab bar controller to the navigation controller, the back button will not be Disable. I want to disable it and add my own custom button.

You need to set the navigation item on the tabBarController, not the view controller. Therefore, If you want to disable the back button from the view controller in the tabBarController inside the navigationController, you can use the following code:

self.tabBarController.navigationItem.hidesBackButton = NO; 

Leave a Comment

Your email address will not be published.