[英]How to add Navigation bar programmatically by clicking the button
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. 我有登录,注册和重置viewControllers我已经将UINavigation控制器连接到登录控制器,但是当我通过单击诸如signup
或reset password
之类的按钮转到其他视图控制器时,目标控制器将出现而没有导航栏。 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)
}
For display navigation bar you need to add your SignUpViewController
in UINavigationController
you can add directly in storyboard By 对于显示导航栏,您需要在UINavigationController
添加SignUpViewController
,您可以直接在Storyboard中添加By
Selecting SignUpViewController -> Editor Menu -> Embed in -> Navigation Controller 选择SignUpViewController->编辑器菜单->嵌入->导航控制器
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)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.