相关疑难解决方法(0)

Xamarin IOS隐藏栏后退按钮

我试图在某个视图上隐藏我的导航控制器的后退按钮(使用故事板)

我试图隐藏栏后退按钮覆盖ViewWillAppear,但似乎没有发生.

这是代码:

public override void ViewWillAppear (bool animated)
{
    base.ViewWillAppear (animated);
    this.NavigationController.NavigationItem.SetHidesBackButton (true, true);
}
Run Code Online (Sandbox Code Playgroud)

c# xamarin.ios viewwillappear ios xamarin

3
推荐指数
1
解决办法
6162
查看次数

在 Xamarin 中隐藏后退按钮文本

我想在 iOS 上的 Xamarin 中隐藏后退按钮的文本,我试过:

<Style TargetType="NavigationPage">
<Setter Property="BackButtonTitle" Value="" />
</Style>
Run Code Online (Sandbox Code Playgroud)

和这个代码:

<Style TargetType="ContentPage">
<Setter Property="NavigationPage.BackButtonTitle" Value="" />
</Style>
Run Code Online (Sandbox Code Playgroud)

但文字仍然出现

解决了:

iOS渲染器:

[assembly: ExportRenderer(typeof(ContentPage), typeof(BackButtonPag))]
[assembly: ExportRenderer(typeof(NavigationPage), typeof(BackButtonNav))]

public class BackButtonPag : PageRenderer
    {
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            if (NavigationController != null)
                NavigationController.TopViewController.NavigationItem.BackBarButtonItem = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, null);
        }
    }

    public class BackButtonNav : NavigationRenderer
    {
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            NavigationBar.TopItem.BackBarButtonItem = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, null);
        }
    }
Run Code Online (Sandbox Code Playgroud)

也添加这个

NavigationPage.BackButtonTitle = ""
Run Code Online (Sandbox Code Playgroud)

到 …

user-interface xaml ios xamarin

3
推荐指数
1
解决办法
1520
查看次数

标签 统计

ios ×2

xamarin ×2

c# ×1

user-interface ×1

viewwillappear ×1

xamarin.ios ×1

xaml ×1