如何为LoginViewController隐藏NavigationBarHidden并为DashBoardViewController显示
window = new UIWindow (UIScreen.MainScreen.Bounds);
navigationController = new UINavigationController();
loginViewController = new LoginViewController ();
navigationController.SetNavigationBarHidden (true,true);
navigationController.AddChildViewController (loginViewController);
if (validAuth == "AuthenticationValidUser" ){
var dashBoardViewController = new DashBoardViewController ();
navigationController.SetNavigationBarHidden (false,true);
navigationController.AddChildViewController (dashBoardViewController);
}
window.RootViewController = navigationController;
window.MakeKeyAndVisible ();
return true;
请以正确的方式给我建议。
@All 提前谢谢。
答案 0 :(得分:5)
您可以在具体的View Controller中访问NavigationController属性,例如在ViewWillAppear中并将其设置在那里。例如:
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
//hide
NavigationController.NavigationBarHidden = true;
//show
//NavigationController.NavigationBarHidden = false;
}