我试图在某个视图上隐藏我的导航控制器的后退按钮(使用故事板)
我试图隐藏栏后退按钮覆盖ViewWillAppear,但似乎没有发生.
这是代码:
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
this.NavigationController.NavigationItem.SetHidesBackButton (true, true);
}
Run Code Online (Sandbox Code Playgroud) 我想在 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)
到 …