I have a TabBarController built into the container view. The first tab has a collection view, and on didselectitematindex I call
tabBarController?.selectedIndex = 1
and it will successfully switch to another controller. HOWEVER, when I call
tabBarController?.selectedIndex = 0
it does not switch to index 0. In fact, it does nothing. I tried putting the button on selectedIndex 2 and calling this command, but it does not work. I tried adding myself. on a call but not working. I tried to call a function that makes a call, but that does not work either. I also made sure my tabBarController has the storyboard identifier "tabBarController". My tabBarController doesn't have a class attached to it, but I don't think it is needed because the first View controller controller worked without it.
What is wrong here?
I think it matters why it doesn't work if someone can give me another way to switch view controllers programmatically.
Let me know if you need more information.
Projectlocated here on github
https://github.com/applegaming/hots-buddy
Apple source
share