Che*_*tty 5 uitabbarcontroller ios
如何将setSelectedIndex设置为UITabBarController以显示More View中存在的视图控制器。
我尝试使用以下代码设置索引
// To redirect user to home screen
TBDDashboardTabBarController *tabBar = segue.destinationViewController;
[tabBar setSelectedIndex:5];
Run Code Online (Sandbox Code Playgroud)
但由于 iOS 最多只会显示 5 个选项卡,并且索引超出了可见选项卡,因此未显示索引视图控制器。
如果我将setSelectedIndex设置为0 到 3,效果[tabBar setSelectedIndex:2];会很好。仅当我尝试将索引设置为大于 3 时,问题才会出现。
我在Google、stackoverflow和其他论坛上尝试过,但没有成功。最接近的提示是如何获取 UIMoreListControllers 子视图控制器
请帮我解答这个谜题。
您可以使用 显示您需要的控制器selectedViewController。SWIFT代码:
destination.selectedViewController = destination.viewControllers![4]
Run Code Online (Sandbox Code Playgroud)