“Default” view in UITabBarController

2019-07-07 17:28发布

I have a UITabBarController with 5 NavigationControllers, embedded in it as tabs (similar to picture 1 below). So, the question is: I want to show the table view (or any another view) as a "default" view, when the TabBarController is shown. I.e., show the view (view controller), which is not embedded in TabBarController and make any tab selected. I apologize for such explanation, better watch on picture #2 below. I'm using latest version of XCode and Swift in my project. And for interface I'm using storyboard

Picture 1

Picture 2

1条回答
劳资没心,怎么记你
2楼-- · 2019-07-07 18:00

You can determine which tab to select in the first (initial) viewController.

Note: Swift 3

override func viewDidLoad() {
    super.viewDidLoad()

    self.tabBarController?.selectedIndex = 1
  }

Note that by default the first selected viewController is at 0 index (self.tabBarController?.selectedIndex = 0)

查看更多
登录 后发表回答