let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
if userSignedInGlobal == "success"{
if let mainTabController = storyboard.instantiateViewController(withIdentifier: "MainTabController") as? MainTabController{
mainTabController.present(mainTabController, animated: true, completion: nil)
}
}
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modal view controller on itself. Presenting controller is .'
I need to navigate to a page after Authenticating application with firebase to do so I use the above code after validating the authentication. How do I fix this an reference link or code explaining how to get there would suffice.
If you are in a UIViewController, then change this line:
self.present(mainTabController, animated: true, completion: nil)
If you are in the Appdelegate then set your ViewController as the root view controller of the window
property:
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
if userSignedInGlobal == "success"{
if let mainTabController = storyboard.instantiateViewController(withIdentifier: "MainTabController") as? MainTabController{
window?.rootViewController = mainTabController
window?.makeKeyAndVisible()
}
}
Remove the controller before present, so instead of
mainTabController.present(mainTabController, animated: true, completion: nil)
use just:
present(mainTabController, animated: true, completion: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With