@IBAction func activateDidTouch(_ sender: AnyObject) {
/*Testing transitioning to another view controller just by a button click**/
print("Activate Did Touch was triggered")
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc: LoginViewController = storyboard.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
self.navigationController?.pushViewController(vc, animated: true)
}}
当我单击与该功能连接的按钮时,什么也没发生。
确实会打印出来:
print("Activate Did Touch was triggered")
我已经验证了ViewController标识符。因此,从理论上讲,所有事情都应该起作用。
答案 0 :(得分:-1)
我尝试了提到的第二种方法here,它解决了我的问题:
let vc = self.storyboard?.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
//self.navigationController?.pushViewController(vc, animated: true)
self.present(vc, animated: true, completion: nil)