Reputation: 2408
I have Login, Signup and Reset viewControllers I have connected the UINavigation controller to login controller but when I go to other view controllers by clicking the button like signup
or reset password
the destination controller appears without navigation bar. help to include navigation bar programmatically when I click the below button.
@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)
}
Upvotes: 0
Views: 176
Reputation: 3310
For display navigation bar you need to add your SignUpViewController
in UINavigationController
you can add directly in storyboard By
Selecting SignUpViewController -> Editor Menu -> Embed in -> Navigation Controller
OR
you can add programmatically like this
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)
}
Upvotes: 1