简体   繁体   English

Xamarin IOS隐藏栏后退按钮

[英]Xamarin IOS hide bar back button

I am trying to hide the back button from my navigationcontroller on a certain view(using storyboard) 我试图在某个视图上隐藏我的导航控制器的后退按钮(使用故事板)

I tried to hide the bar back button overriding the ViewWillAppear , but it does not seem to happen. 我试图隐藏覆盖ViewWillAppear的栏后退按钮,但似乎没有发生。

Here is the code: 这是代码:

public override void ViewWillAppear (bool animated)
{
    base.ViewWillAppear (animated);
    this.NavigationController.NavigationItem.SetHidesBackButton (true, true);
}

just change to : 只需改为:

public override void ViewDidLoad ()
{
    base.ViewDidLoad ();

    this.NavigationItem.SetHidesBackButton (true, false);
}

Below is the best answer which works well with xamarin forms too Add this code in App delegate.This solved my problem too 下面是最适合xamarin表单的答案。在App delegate中添加此代码。这也解决了我的问题

UIBarButtonItem.Appearance.SetBackButtonTitlePositionAdjustment (new UIOffset (-100, -60), UIBarMetrics.Default); UIBarButtonItem.Appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(-100,-60),UIBarMetrics.Default);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM