instantiated view controller displays for 1 second then segues to next view controller for no reason
I'm having an issue when it comes to instantiating a view controller and actually having it stay on the screen without automatically jumping to the next view controller. I setup a view controller sort of identical to another view controller I have in my project, but the class names are completely different obviously.
Now I want to instantiate this view controller when a user finishes signing up. So I do that in this block of code:
{
//Create user
Auth.auth().createUser(withEmail: schoolEmail, password: schoolPassword) { (result, error) in
guard error == nil else {
self.showAlert(title: "Error Signing Up", message: "There was an error creating the user, please check your connection and try again later.")
return
}
let db = Firestore.firestore()
guard let result = result else { return }
db.document("school_users/\(result.user.uid)").setData(["school_name":schoolName,
"school_id":schoolID,
"remindersPushNotificationsOn": true,
"updatesPushNotificationsOn": true,
"schoolDistrict":schoolDistrict,
"time_created":dateCreated,
"userID": result.user.uid],
merge: true) { (error) in
guard error == nil else {
self.showAlert(title: "Error Signing Up", message: "There was an error creating the user, please check your connection and try again later.")
return
}
}
let changeRequest = result.user.createProfileChangeRequest()
changeRequest.displayName = schoolName
changeRequest.commitChanges { (error) in
guard error == nil else {
return
}
print("School Name Saved!")
}
}
guard let nextVC = storyboard?.instantiateViewController(withIdentifier: Constants.StoryboardIDs.SchoolOnboarding) as? SchoolSignUpOnboardingViewController else { return }
navigationController?.pushViewController(nextVC, animated: true)
}
This works, but to an extent. When I finish signing up, the view controller is displayed for literally a split second with the proper UI and everything and it then automatically segues to the next view controller which makes no sense. This has never happened to me with segues before and I can't understand why it's happening now.
I used TestFlight with my friends last night and for some reason bits of my code just completely turned it's back on me when I was trying to test certain functionalities. I wanted to also add a new addition which was this view controller I want to instantiate but now this addition to the app won't even work properly. So with this in mind, I was wondering if it's an issue with the TestFlight and the app's build number, so I incremented the build number and tried to run the app on the simulator again, but it still didn't keep the view controller on the screen and just kept jumping to the next view controller automatically.
This is so frustrating because I genuinely can't figure out what the cause of this view controller issue is. Any suggestions?