2017-04-11 38 views
0

enter image description here我想以編程方式擴展到新的ViewController,但是當我做我的tabBar消失。TabBar在程序化階段消失

if user == usernameStored && pass == passwordStored{ 
     print("Good") 
     let vc = self.storyboard?.instantiateViewController(withIdentifier: "home") 
     self.present(vc!, animated: true, completion: nil) 



    } 
+0

鏈接到標籤欄視圖控制器? –

+0

是其對main.storyboard – Johnd

+0

你能證明你的故事板圖像? –

回答

1

從你的代碼,這不是segue通過編程方式。你實際上是present a viewController無論你有什麼。因此tabBarController是封面。

要在代碼中使用segue,它應該是這樣的。 - homeSegueID是您在故事板中創建segue時給出的identifier

performSegue(withIdentifier: "homeSegueID", sender: nil) 

如果你只是想以編程方式做到這一點不segue,你可以這樣做,而不是。 (這個假設您目前ViewController處於UINavigationController堆棧。

navigationController?.pushViewController(vc, animated: true) 
1

導航控制器是否將視圖控制器封裝爲標籤欄控制器,還是隻是將標籤欄添加到視圖控制器?這是你應該做的事情:

Tab Bar Controller