[英]how to push programmatically made view controller with swift 3
I have created a TableViewController
and embedded it in a navigationController
(no storyboards): 我创建了一个
TableViewController
并将其嵌入到navigationController
(没有情节提要):
class editFullnameNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
self.setToolbarHidden(false, animated: true)
}
override init(rootViewController: UIViewController) {
let editFullnameTableViewControllerClass = editFullnameTableViewController(style: .grouped)
super.init(rootViewController: editFullnameTableViewControllerClass)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
}
class editFullnameTableViewController: UITableViewController, UITextFieldDelegate {
}
I want to push this editFullnameTableViewController
with touching a button in another viewController
using : 我想按这个
editFullnameTableViewController
与触摸在另一个按钮viewController
使用:
let editfullnameNavigationControllerPage = editFullnameNavigationController(rootViewController: editFullnameTableViewController(style: .grouped))
self.navigationController?.pushViewController(editfullnameNavigationControllerPage, animated: true)
but its not working. 但它不起作用。 How can I do this?
我怎样才能做到这一点? Thanks.
谢谢。
just create a instance view controller and push to viewcontroller 只需创建一个实例视图控制器并推送到viewcontroller
let controller = editFullnameTableViewController()
self.navigationController?.pushViewController(controller, animated: true)
NavigationController Subclass cannot be pushed on NavigationController Stack NavigationController子类无法推入NavigationController堆栈
You can present it with present method 你可以用现在的方法展示它
//create instence
let navController = editFullnameTableViewController() //Navigation controller
//present method
self.navigationController?.present(navController, animated: true, completion: nil)
Or You can set New Navigation Controller as Root of window 或者您可以将“新导航控制器”设置为窗口根
self.window?.rootViewController = navController
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.