Reputation: 624
I want to segue to a new ViewController programatically but when I do my tabBar disappears.
if user == usernameStored && pass == passwordStored{
print("Good")
let vc = self.storyboard?.instantiateViewController(withIdentifier: "home")
self.present(vc!, animated: true, completion: nil)
}
Upvotes: 0
Views: 64
Reputation: 5757
From your code, this is not segue
by programmatically. You actually present
a viewController
on top of whatever you have. Therefore the tabBarController
is cover.
To use segue
in code, it should be something like this. - homeSegueID
is the identifier
you give when you created the segue
in storyboard.
performSegue(withIdentifier: "homeSegueID", sender: nil)
If you just want to do it programatically without segue
, you could do this instead. (This assume your current ViewController
is in a UINavigationController
stack.
navigationController?.pushViewController(vc, animated: true)
Upvotes: 1
Reputation: 6705
Is the navigation controller wrapping your view controllers a tab bar controller, or did you just add the tab bar to your view controller? This is what you should be doing:
Upvotes: 1