The question sounds a bit confusing but I don't know how to describe it better.. Let me explain:
The first ViewController that gets presented is FirstLaunchVC, where he user types in his email and if he is registered he get's to LoginVC and from there he get's to MainVC. Everything is working fine.
In MainVC the user can sign out and get's back to FirstLaunchVC. However, after doing the weiterButton which should bring the user to LoginVC is not doing anything.
FirstLaunchVC:
@objc func weiterButtonTapped() {
email = emailTextfield.text!.trimmingCharacters(in: .whitespacesAndNewlines)
//prüfen, ob Email schon registriert ist
Auth.auth().fetchSignInMethods(forEmail: email) { (methods, error) in
//Email ist noch nicht registriert -> sign up
if methods == nil {
let SignUpView = self.storyboard?.instantiateViewController(withIdentifier: "SignUpVC") as! SignUpViewController
SignUpView.email = self.email
self.navigationController?.pushViewController(SignUpView, animated: false)
}
//Email ist registriert -> login
else {
print("hi")
self.view.endEditing(true)
let LoginView = self.storyboard?.instantiateViewController(withIdentifier: "LoginVC") as! LoginViewController
LoginView.email = self.email
self.navigationController?.pushViewController(LoginView, animated: true)
}
}
}
Main Problem:
The print(hi) is printing but pushViewController is not working after signing out.
LoginVC:
func transitionToHome () {
let homeVC =
storyboard?.instantiateViewController(withIdentifier: Constants.Storyboard.homeViewController) as? MainViewController
let navigationController = UINavigationController(rootViewController: homeVC!)
view.window?.rootViewController = navigationController
view.window?.makeKeyAndVisible()
}
MainVC:
This is where the user can sign out.
@objc func signoutButtonTapped() {
UserDefaults.standard.setIsLoggedIn(value: false)
UserDefaults.standard.synchronize()
let firstLaunchVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FirstLaunchVC")
self.navigationController?.present(firstLaunchVC, animated: true)
}
I tried to explain the problem the best I can. If anything is still unclear just let me know. I am happy for any help :)