Search code examples
iphoneobjective-cuinavigationcontrollerback-button

Disable navigationitem backbarbutton


How do I disable the backbutton in a navigationcontroller?

When I hide the button like so, self.navigationItem.hidesBackButton = TRUE; the buttonarea is still tappable.


Solution

  • If you don't need a back button and since part of navigationBar's existence is to have a back button you can simply hide the navBar. I can post the code to that if you want as Im doing that in couple of projects. Otherwise have your "bug" might not be a bug if you are calling it from the wrong place. After digging i managed to come up with this. To hide the back button use:

    self.navigationItem.hidesBackButton = YES;
    

    To hide the whole navigationBar use:

    self.navigationController.navigationBarHidden = YES;
    

    But this will happen without animation, to animate it use this instead:

    [self.navigationController setNavigationBarHidden:YES animated:YES];
    

    This will make a sliding animation together with the navigation view. You will need to provide some other means for the person to get back tho.