我有一个 viewcontroller ,我把它命名为SelectionPopUpViewController
。我将该控制器嵌入UINavigationController
。
从SelectionPopUpViewController.swift
,我说:
@IBAction func okTapped(sender: AnyObject) {
self.dismissViewControllerAnimated(false, completion: nil)
let homeVc = UIStoryboard(name: "Home", bundle: nil).instantiateViewControllerWithIdentifier("Home") as HomeViewController
self.navController = UINavigationController(rootViewController: homeVc)
self.window?.rootViewController = self.navController
//self.navController.pushViewController(homeVc, animated: true)
}
在上面我说:
weak var window : UIWindow?
var navController : UINavigationController!
我想要的是当用户点击okTapped
按钮时,它会转到HomeViewController
。我尝试初始化,但它不起作用。也许我的初始化错了。
使该按钮有效的正确代码是什么(转到HomeViewController
)?