Am new to Swift and Storyboard. At initially I have to show the login page and from the login page to UITabBarController. Once the user remembered the login details I have to check the login details in the AppDelegate and show the UITabBarController directly if the user already logged in. I have referred some SOF questions but, am not getting the result.
I designed the LoginViewController embedded with UINavigationController. And I have one UITabBarController with 2 viewcontrollers. I set the LoginViewController as a inititialViewController in Storyboard. So the loginview is showing at very first time. But, I don't know how to push the UITabBarController from the login screen (Login Button Action). Also I don't know how to check and load the login and tabbar
respectively from appDelegate.
Can anyone please help me? Thanks in advance.
@IBAction func loginButtonAction (button : UIButton) {
if isRemeberLogin == true {
let loginClass = LoginModelClass(userNameValue: (usernameTF?.text)!, passwordValue: (passwordTF?.text)!)
print("Remembering Login Details: \(loginClass.userName, loginClass.passWord)")
}
let homeVC = self.storyboard?.instantiateViewControllerWithIdentifier("HomeViewController") as! HomeViewController
let collectionVC = self.storyboard?.instantiateViewControllerWithIdentifier("ItemsCollectionViewController") as! ItemsCollectionViewController
//self.navigationController?.pushViewController(homeVC, animated: true)
let tabBarController = self.storyboard?.instantiateViewControllerWithIdentifier("TabBarController") as! UITabBarController
print("TABBAR \(tabBarController)")
let viewControllersArray = [homeVC, collectionVC];
// tabBarController?.viewControllers = viewControllersArray
self.navigationController?.pushViewController(tabBarController, animated: true)
}
Thank you for the answers. I resolved the issue and here is my code.
This is from Login Button Action:
Just mention the "TabBarController" as Identity in Storyboard for the UITabBarController. I have created a Viewcontroller embedded with UINavigationController and UITabBarController with three UIViewControllers separately.
I hope it will help someone else. Thanks.
Please check in
image
your storyboard must be look like following.Then give
Storyboard Segue
identifier which navigate you toUITabbarController
fromLoginViewController
.Then
paste
following code from where you want to navigate.