如何在导航控制器上启用/添加后退按钮?

发布于 2025-01-06 00:54:44 字数 796 浏览 1 评论 0原文

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

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

            } 

已经尝试过这个,但还没有工作:

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

            this.NavigationItem.SetHidesBackButton(false,true);

         }

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);

         }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乞讨 2025-01-13 00:54:44

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

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

    }
}

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)
    {

    }
}
妄司 2025-01-13 00:54:44

您能提供一些背景信息吗?这个 ViewController 如何添加到 NavigationController 中?

如果您使用 PushViewController 方法(如下所示),则会自动添加后退按钮。

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

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

If you use the PushViewController method (as below) then a back button will be automatically added.

var viewController = new UIViewController();
this.NavigationController.PushViewController(viewController, true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文