4
votes

I've tried various ways of hiding the back button of my UINavigationController

UINavigationController RVC = new UINavigationController();
other code
RVC.NavigationItem.SetHidesBackButton(true,true);   

and other similar ways, but none of them have actually hidden the back button. Does anyone know what I'm doing wrong?

1
Try to use this.NavigationItem.SetHidesBackButton(true,true); within the controller you are pushing in the navigation controller. For example override viewWillAppear and put the code there. - Lorenzo B
@Flex_Addicted That worked perfectly, thank you! - Smoore
Maybe I could answer your question..to have some points :-) - Lorenzo B
Smoore, I answered you question. Have a nice day. - Lorenzo B
I added a simple note. It could help you to understand something else. Cheers. - Lorenzo B

1 Answers

6
votes

Use this.NavigationItem.SetHidesBackButton(true,true); within the controller that it is pushed in the navigation controller. You could override ViewWillAppear and put the code there like:

public override void ViewWillAppear (bool animated)
{
    base.ViewWillAppear (animated); 

    this.NavigationItem.SetHidesBackButton(true,true);
}

Hope it helps.

A simple note

Since the navigation bar is unique for a UINavigationController, the button will maintains its state for all the controllers you push in the navigation controller. To explain the concept suppose you have two controllers, say A and B. You first push A and in its ViewWillAppear method you hide the button. When you push B, the button still remains not visible. If you want to unhide the button in B, you can play with its ViewWillAppear method (like before) and so on...