UITabBarController以Swift语言设置默认选项卡
我有一个UITabBarController有5个不同的视图控制器附加到它。 每个人都有自己的特定标签,如家庭,设置等。我怎样才能设置一个特定的选项卡启动时的默认选项卡?
是否有一个特定的原因,你不能移动你select的第一个标签提交到最左边的插槽?
self.tabBarController.selectedIndex = desiredIndex
或者,如果您的代码位于UITabBarConroller子类中,则只需:
selectedIndex = desiredIndex
应该pipe用。
你可以考虑改变应用程序委托的didFinishLaunchingWithOptions
(或任何拥有标签栏控制器)的选项卡,像这样的代码:
if let tabController = window?.rootViewController as? UITabBarController { tabController.selectedIndex = 1 }