我尝试了多种方法来隐藏我的 UINavigationController
UINavigationController RVC = new UINavigationController();
other code
RVC.NavigationItem.SetHidesBackButton(true,true);
和其他类似的方式,但它们都没有真正隐藏后退按钮。有谁知道我做错了什么?
最佳答案
在 Controller 中使用 this.NavigationItem.SetHidesBackButton(true,true);
将其推送到导航 Controller 中。您可以覆盖 ViewWillAppear
并将代码放在那里:
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
this.NavigationItem.SetHidesBackButton(true,true);
}
希望对您有所帮助。
一个简单的笔记
由于导航栏对于 UINavigationController
是唯一的,因此按钮将为您在导航 Controller 中推送的所有 Controller 保持其状态。为了解释这个概念,假设您有两个 Controller ,比如 A 和 B。您首先按下 A,然后在它的 ViewWillAppear
方法中隐藏按钮。当您按下 B 时,按钮仍然不可见。如果你想取消隐藏 B 中的按钮,你可以使用它的 ViewWillAppear
方法(像以前一样)等等......
关于iphone - 如何隐藏 UINavigationController 的后退按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12183708/