我有HomeViewController thats位于索引0处的主tabBarController的UINavigation根视图控制器。此外,我有SecondViewController作为UINavigation根视图控制器在选项卡索引1上,我需要以编程方式切换选项卡。所以当我在SecondViewController中完成编辑操作时,我需要显示标签索引0和他嵌套的UINavigation根视图控制器。从其他tabBar索引以编程方式选择tabBarController索引
我试图用
self.tabBarController.selectedIndex = 0;
这种变化指数,但视图控制器不会改变。它保持在相同的观点。
也试过
self.navigationController.tabBarController.selectedViewController = [self.navigationController.tabBarController.viewControllers objectAtIndex:0];
相同的结果如上:(
,这是所有的iOS 8.0+
这是切换索引的正确方法,您可能在y中有一个错误我们的代码在别处 – Michael