问题
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
回答1:
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
)
来源:https://stackoverflow.com/questions/31015475/default-view-in-uitabbarcontroller