删除导航栏中的后退箭头,保留后退按钮标题

时间:2018-06-21 07:26:32

标签: ios xamarin xamarin.forms navigationbar

我有xamarin表单ios应用程序,我需要在其中删除导航栏中的后退箭头,但是标题应该显示,并且当用户单击该后退按钮标题时,它应该导航至上一个视图。  我尝试使用`

NavigationPage.SetBackButtonTitle(this, "Cancel");

NavigationPage.SetHasBackButton(this, false);

但是后退箭头仍在显示,为什么没有一个Cancel符号的文本<

3 个答案:

答案 0 :(得分:1)

我通过如下添加自定义渲染器解决了我的问题

public override void ViewWillAppear(bool animated)
{      
    base.ViewWillAppear(animated);
    this.NavigationController.TopViewController.NavigationItem.LeftBarButtonItem =new UIBarButtonItem(“Cancel”, UIBarButtonItemStyle.Plain, (sender, args) => { });      
}

答案 1 :(得分:0)

在您的AppDelegate.cs文件的FinishedLaunching方法中,添加以下行:

UINavigationBar.Appearance.BackIndicatorImage = new UIImage();
UINavigationBar.Appearance.BackIndicatorTransitionMaskImage = new UIImage();

但是,这将删除每个页面。如果您只想要一页,那么我建议您像已经提到的EvZ:使用模式页面或其他方式。

另一种方法是将上述行设置为null,这将恢复正常箭头。但这意味着实现自定义渲染器,依赖项服务或类似功能。

答案 2 :(得分:0)

删除导航栏,并在导航位置上使用图像/标题,然后将图像/标题写入导航标题 ...

图像onclick事件写入回写命令