I have a UITabBarController
which containing 4 different UIViewControllers
.
On first tab there is a UINavigationViewController
If you are presenting a new controller (different from the one that's currently on screen) you should set the index in the completion block of the function to present your view controller. If you set it before it's presented, it may not work.
In my case I've embedded the tab controller inside a nav controller. I present the new nav controller newNavContoller
, and once it's presented I set the index in my tab controller tvc
:
currentViewController?.presentViewController(newNavController, animated: true, completion: {tvc.selectedIndex = selectedIndex})