vanelizarov
vanelizarov

Reputation: 1073

"Default" view in UITabBarController

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

Upvotes: 2

Views: 1584

Answers (1)

Ahmad F
Ahmad F

Reputation: 31645

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)

Upvotes: 2

Related Questions