I have Login.storyboard
:
The Login View Controller
has a Segue to a Storyboard Reference and the storyboard main.storyboard
:
My LoginViewController class code has a TouchUpInside action handler that programmatically calls the segue to main.storyboard
:
@IBAction func btnLoginTouchUpInside(sender: UIButton) {
let params = AuthLoginParams(Username: txtFieldUsername.text!, Password: txtFieldPassword.text!)
AuthLoginRequest.FetchUser(params) { (userModel) -> Void in
if(userModel.IsAuthorized){
self.performSegueWithIdentifier("mainStoryboardSegue", sender: nil)
}else{
}
}
}
Now let's look at main.storyboard
So from Login.storyboard
-> successful login segue -> Main.storyboard
I am trying to segue "out" of a UINavigationController
stack and start new/fresh with a UITabBarController
. Here is a screen shot if I start my app with main.storyboard
and skip the Login.storyboard
:
But if I start my app with Login.storyboard
and the try using my segue to Stoyboard Reference main.storyboard
with self.performSegueWithIdentifier("mainStoryboardSegue", sender: nil)
I am still in the Login process UINavBarController stack which I do not want:
Thanks to @Paulw11's tip in my question comments, he stated that I cannot do what I am trying to with a simple segue, I have to programmtically change the rootViewController and this is the code I came up with, including a transition amimation and all seems to be working nicely:
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewControllerWithIdentifier("dashboardTabBarController") as! DashboardTabBarController
UIView.transitionWithView(self.view.window!, duration: 0.5, options: UIViewAnimationOptions.TransitionCrossDissolve, animations: {
UIApplication.sharedApplication().keyWindow?.rootViewController = viewController;
}, completion: nil)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.