如何在NavigationController上启用/添加BackButton?

Mem*_*mer 4 c# uinavigationcontroller uibarbuttonitem xamarin.ios uinavigationitem

我尝试了很多方法,但没有成功.

通过这种方式,我可以创建一个新的UIBarButtonItem并且它可以工作,问题是它像lockButton/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);  
                    }); 

            } 
Run Code Online (Sandbox Code Playgroud)

尝试了这个,但没有奏效:

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

            this.NavigationItem.SetHidesBackButton(false,true);

         }
Run Code Online (Sandbox Code Playgroud)

Anu*_*nuj 10

使用MonoTouch.Dialog,您必须设置"推"标志才能显示后退按钮.您可以在构造函数中执行此操作,如下所示:

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

    }
}
Run Code Online (Sandbox Code Playgroud)