Reputation: 253
SoI have a Tab bar based app, but which is supposed to go trough a login / Signup process first. The Signup and Login works fine and I was able to move to a new ViewController and set it to be the new root VC with a function ` func transitionToHome(){
let homeViewController = storyboard?.instantiateViewController(identifier: Constants.Storybord.HomeViewController) as? homeViewController
view.window?.rootViewController = homeViewController
view.window?.makeKeyAndVisible()
}`
This was all working fine and I decided to move along and start building the tabbed ui, thats when I ran intro problems. As seen in my Main Storyboard can be seen here, the structure is simple. How do I connect the Login and Signup Buttons with something else than a ViewController, so for example the Tab Bar Controller? I managed to get to one of the Tabs but that didn't cut it either because I would then lose the ability to navigate between them.. I am in my first days of swift so I would love to hear any tips. I bet its not that hard after all.
Right now I am trying to get it to work by giving my Tab Bar Controller a Storyboard ID which I am then looking for in my modified version of the code above. Since i cannot add a ViewController for the Tab Bar Controller I am then starting the Tab Bar Item I want to have as default, but this just gives me a black screen..
Upvotes: 0
Views: 1494
Reputation: 253
Okey I found the issue. Thanks @Paulw11 for pointing out that a Tab Bar Viewcontroller can be used just like a normal view controller. The problem was the part " as? MainViewController", this had to say as? UITabBarController and voila, it worked. For anyone in the future, thats how you do it.
Upvotes: 2