UITabBarController可以通过代码选择选项卡吗?
-
08-07-2019 - |
题
是否可以在UITabBarController中选择代码中的选项卡?如UINavigationController 我们可以使用popViewController弹出回rootViewController而不是按下后退按钮,那么如何在tabbarcontroller中实现呢?
解决方案
在UITabBarController上使用selectedIndex属性。更多信息可以在 UITabBarController类参考。
controller.selectedIndex = 4;
或使用
[controller setSelectedIndex:4];
不隶属于 StackOverflow