Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable/add a BackButton on the NavigationController?

I have tried many ways, but haven't succeeded.

In this way I can create a new UIBarButtonItem and it works, the problem is that it dosent lock like a 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);  
                    }); 

            } 

Have tried this, but haven't worked:

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

            this.NavigationItem.SetHidesBackButton(false,true);

         }
like image 252
MemoDreamer Avatar asked Dec 21 '22 02:12

MemoDreamer


1 Answers

With MonoTouch.Dialog you have to set a "pushing" flag in order for it to show the back button. You can do this in the constructor, as indicated below:

public class MyViewController : DialogViewController
{
    public MyViewController
        : base(new RootElement("foo"), true)
    {

    }
}
like image 55
Anuj Avatar answered Dec 24 '22 01:12

Anuj