2017-04-01 83 views
0

我有登錄,註冊和重置viewControllers我已經連接UInavigation控制器登錄控制器,但當我去其他視圖控制器通過點擊像signupreset password按鈕,目標控制器出現沒有導航欄。當我點擊下面的按鈕時,幫助編程式地包含導航欄。如何添加導航欄編程方式通過點擊按鈕

@IBAction func signupButton(_ sender: Any) { 
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
let newViewController = storyBoard.instantiateViewController(withIdentifier: "SignUpViewController") as! SignUpViewController 
self.present(newViewController, animated: true, completion: nil) 
} 
+1

結帳我的回答 –

回答

1

對於您需要添加您的SignUpViewControllerUINavigationController您可以在故事板直接添加到

選擇SignUpViewController顯示導航欄 - >編輯器菜單 - >中嵌入 - >導航控制器

您可以像這樣以編程方式添加

IBAction func signupButton(_ sender: Any) { 
    let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) 
    let newViewController = storyBoard.instantiateViewController(withIdentifier: "SignUpViewController") as! SignUpViewController 
    let naviCon = UINavigationController(rootViewController:newViewController) 
    self.present(naviCon, animated: true, completion: nil) 
} 
+0

謝謝這麼多親愛的@jignesh Vadadoriya –

+0

你好歡迎來 –