Search code examples
uinavigationcontrolleruitabbarcontrolleruinavigationbaruitabbarback-button

How to identify the viewcontroller is clicked from More Tab or Separate tab in UITabBarController?


I have the navigationcontroller based viewcontroller and I overriding the root view controller navigation bar back button in to my custom segment control with different purpose. This navigation controller is placed one of the separate tab in the uitabbarcontroller. If this is used as the separate tab bar then no problem.

But if i use this navigationcontroller inside the more option in tabbarcontroller i am not able to come back to the more option list because of backbutton is overridden in my navigationcontroller.

My idea is add one back button only if my navigationcontroller is used more option tab otherwise i need to hidden the back button.

Please help me in this issue?


Solution

  • You can check if a view controller is in the 'more' section as follows:

    BOOL isOnMoreNavigationController = [tabBarController.moreNavigationController.viewControllers containsObject:myViewController.navigationController];
    

    From a UI consistency perspective it might be better to always show the back button in its standard position and move your custom buttons to some other place.