UITabBarController 在 Swift 语言中设置默认选项卡 [英] UITabBarController Set a Default Tab in Swift Language

查看:35
本文介绍了UITabBarController 在 Swift 语言中设置默认选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITabBarController,它有 5 个不同的视图控制器.每个都有自己的特定选项卡,例如主页、设置等.如何将某个选项卡设置为启动时的默认选项卡?

I have a UITabBarController that has 5 different view controllers attached to it. Each one has there own specific tab such as Home, Settings, etc. How can i set a certain tab to be the default tab when launched?

推荐答案

为什么您无法将所选的第一个选项卡移动到最左侧的位置,是否有特定原因?

Is there a specific reason why you can't move your chosen first tab to be presented to the left most slot?

self.tabBarController.selectedIndex = desiredIndex

或者,如果您的代码在 UITabBarConroller 子类中,只需:

or, if you're code is in a UITabBarConroller subclass, simply:

 selectedIndex = desiredIndex

应该可以.

这篇关于UITabBarController 在 Swift 语言中设置默认选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆