“Default” view in UITabBarController

删除回忆录丶 提交于 2019-12-11 02:41:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!