How to enable / add BackButton in NavigationController?

I tried many ways, but could not.

That way I can create a new UIBarButtonItem and it works, the problem is that it locks the lock as backButton / ArrowBackButton:

public override void ViewWillAppear (bool animated) { base.ViewWillAppear (animated); this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem ("Tillbaka", UIBarButtonItemStyle.Plain, delegate(object sender, EventArgs e) { this.NavigationController.PopViewControllerAnimated (true); }); } 

Tried this, but didn’t work:

  public override void ViewWillAppear (bool animated) { base.ViewWillAppear (animated); this.NavigationItem.SetHidesBackButton(false,true); } 
+4
source share
2 answers

In MonoTouch.Dialog you must set the pushing flag so that it displays the back button. You can do this in the constructor as follows:

 public class MyViewController : DialogViewController { public MyViewController : base(new RootElement("foo"), true) { } } 
+10
source

Can you give some context to this, please? How is this ViewController added to the NavigationController?

If you use the PushViewController method (as shown below), the back button is automatically added.

 var viewController = new UIViewController(); this.NavigationController.PushViewController(viewController, true); 
+1
source

Source: https://habr.com/ru/post/1396634/


All Articles