iPhone - UINavigationItem - hiding back button

iphone, uinavigationitem

Solution

There seems to be some kind of bug regarding the hiding and showing of the back button when dealing with a `UINavigationController`. A similar problem to yours is backButton of NavigationController don't appear.

I did some testing regarding this and while I don't have an explanation here are some suggestions that might help you.

- Only make calls to `setHidesBackButton:animated:` in `viewDidAppear:` and not in `viewWillAppear:`

- Don't use `self.navigationItem.hidesBackButton` anywhere.

Problem

I'm stumped. I'm using a UINavigationController and on one view I'm trying to hide the back button. But when I do that it hides the back button on the next level of views also. In `- (void)viewWillAppear:(BOOL)animated` I have: ``` [self.navigationItem setHidesBackButton:YES animated:NO]; ``` And in `- (void)viewWillDisappear:(BOOL)animated` I have: ``` [self.navigationItem setHidesBackButton:NO animated:NO]; ``` This just makes the back button appear just before it leaves (which seems like that is the correct functionality of that call). Therefore I tired to put ``` [self.navigationItem setHidesBackButton:NO animated:NO]; ``` in `- (void)viewWillAppear:(BOOL)animated` of the next view, and that still doesn't work. This is a little confusing since `self.navigationItem.backBarButtonItem` is a reference of what that view's back button will be when it is the view just under the top view (ref). But `self.navigationItem.hidesBackbutton` is whether the back button is shown when it is the top view (ref). So does anyone have any idea why it would hide the back button of the next view? Another strange thing is it works when I go another view down. For a more visual representation, lets say I have the following views: ``` A > B > C > D ``` B is the view I'm concerned about. I want to hide the back button which would go to A. When I do that it hides the back button on C also. But if I do down to D, the back button shows up and then everything acts as it "should." That is, I can go back to C, then Back to B. B has it's back button hidden and if I go back into C the back button shows up like it should. Any ideas?

Original source