2014-09-03 167 views
0

如何隱藏NavigationBarHidden爲LoginViewController並顯示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; 

請諮詢我有道。

@全部 在此先感謝。

回答

2

您可以在具體的View Controller中訪問NavigationController屬性,例如在ViewWillAppear中並將其設置在那裏。例如:

public override void ViewWillAppear (bool animated) 
{ 
    base.ViewWillAppear (animated); 

    //hide 
    NavigationController.NavigationBarHidden = true; 
    //show 
    //NavigationController.NavigationBarHidden = false; 
} 
+0

同樣的事情我在ViewDidLoad中調用我的應用程序崩潰...... !!!現在,並在ViewWillAppear呼籲它的工作正常...對我感謝你! – kiran 2014-09-03 20:17:56