如何在具有5个以上视图控制器的选项卡栏控制器上手动调用选项卡索引?
我试图手动调用选项卡索引,但它似乎不起作用。我有一个tabview控制器和6个视图控制器。我正在使用selectedIndex调用特定选项卡。在iPhone上,这对前4个标签有效,但对第5和第6个标签无效。它在iPad上运行良好。
这就是我正在使用的:

let getViewController = self.storyboard?.instantiateViewController(withIdentifier: "tabBar") as! UITabBarController
getViewController.selectedIndex = 5
self.navigationController?.present(getViewController, animated: true)

这将导致选项卡栏显示第一个选项卡,而不是预期的第六个选项卡。因为它在iPad上运行良好,我想“更多”标签会使tabindex失效
任何帮助都将不胜感激!

最佳答案

呼叫selectedViewController而不是selectedIndex

关于swift - swift tabBarController selectedIndex不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50749442/

10-12 05:58