I have two different storyboards:
The Loginstoryboard should be used when the user is not logged in or the user logged out. Then there should be a segue to the Mainstoryboard.
How could I implement it in swift?
Looking forward to your answers!
Jan
Have you tried switching your rootViewController
in application(_:didFinishLaunchingWithOptions:)
Assuming Mainstoryboard
has your rootViewController
:
if userIsNotLoggedIn {
let storyboard = UIStoryboard(name: "Loginstoryboard", bundle: nil)
let loginController = storyboard.instantiateViewControllerWithIdentifier("LoginNavigationController") as UINavigationController
window?.rootViewController = loginController
}
To switch view controllers once logged in you can do this:
func loggedIn() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let mainController = storyboard.instantiateViewControllerWithIdentifier("MainVC") as UIViewController
let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
appDelegate.window?.rootViewController = mainController
}
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