我有两个UITabController
s。一个可以从UIViewController
嵌套在第一个范围内的 s 中控制UITabController
(在层次结构中较低)。当我更改selectedIndex
层次结构中较低的一个时,它也会更改另一个。我尝试了很多东西(见下文),但似乎没有任何效果。知道如何控制一个而不是另一个。
// Controls both
self.tabBarController!.selectedIndex = curTab
// Doesn't do anything
(self.storyboard?.instantiateViewController(withIdentifier: "SecondTabBar") as! UITabBarController).selectedIndex = curTab
// Where stb is via classes to the storyboard of UITabController also doesn't work
stb.selectedIndex = curTab