登录完成后,我正在努力从 NavigationStack 中关闭 UIViewController。
登录屏幕是一个 UIViewController,显示了这行代码
let loginController = LoginController()
self.present(loginController, animated: true, completion: nil)
然后我运行这段代码让用户通过 firebase 登录。
Auth.auth().signIn(withEmail: email, password: password) { (user, err) in
if let err = err {
print("Failed to sign in user with email", err )
}
//self.dismiss(animated: true, completion: nil)
let userProfileVC = UserProfileController()
let navController = UINavigationController(rootViewController: userProfileVC)
self.navigationController?.pushViewController(navController, animated: true)
}
如您所见,我已经尝试了 pushViewController 方法,并且还尝试了注释的 self.dismiss 方法?我所做的一切似乎都没有删除 loginController UIView 并将我带回 UINavigationController 主屏幕。谁能帮帮我,非常感谢。
最佳答案
你可以这样做
self.dismiss(animated: true, completion: {
let userProfileVC = UserProfileController()
let navController = UINavigationController(rootViewController: userProfileVC)
self.navigationController?.pushViewController(navController, animated: true)
})
关于ios - 成功登录后无法关闭 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54106462/