Существует несколько способов решения вашей проблемы, но я бы сказал, что все они не являются современными, потому что каждая вкладка в TabbarController должна иметь свой собственный NavigationController.:)
Может быть, этот способ работает для вас:
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
print("the selected index is : \(tabBar.items?.index(of: item))")
if tabBar.items?.index(of: item) == 0 {
let vc = YourSecondViewController() //or get it from your Storyboard
self.navigationController.setViewControllers([vc], animated: true)
}
}
ОБНОВЛЕНИЕ
Или, если вы нажмете свой контроллер, вы можете попробовать этот
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
print("the selected index is : \(tabBar.items?.index(of: item))")
if tabBar.items?.index(of: item) == 0 {
self.navigationcontroller.popToRootViewController(animated: true)
}
}