Smoore
Smoore

Reputation: 772

How to hide the Back Button of UINavigationController?

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?

Upvotes: 4

Views: 1907

Answers (1)

Lorenzo B
Lorenzo B

Reputation: 33428

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...

Upvotes: 6

Related Questions