[英]Xcode: How can I change the "Default" Tab in a TabBar
I've got an iOS App with a TabBarController
in the MainStoryboard
.我在
MainStoryboard
有一个带有TabBarController
的 iOS 应用程序。 The Tab Bar works fine but I have 5 Tabs, and now the Tab which is selected by default is the first one, but I want the middle one (in that case the 3rd --> Index:2) to be selected by default.标签栏工作正常,但我有 5 个标签,现在默认选择的标签是第一个,但我希望默认选择中间的一个(在这种情况下是第三个 --> 索引:2)。
I've found an answer here on stack overflow ( Setting the default tab when using storyboards ), but for some reason its not working for me.我在这里找到了关于堆栈溢出的答案( 使用故事板时设置默认选项卡),但由于某种原因它对我不起作用。 How can I manage that instead?
我该如何管理呢?
Thank you in Advance!先感谢您!
set the selectedIndex of the tabBarController.设置 tabBarController 的 selectedIndex。
var Launching = true
override func viewWillAppear(animated: Bool) {
if Launching == true {
Launching = false
self.tabBarController.selectedIndex = 2 // 3th tab
}
}
I hope it will works for you ... :)我希望它对你有用... :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.