"Default" view in UITabBarController

1.5k Views Asked by At

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

There are 1 best solutions below

2
On

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)