Setting default tab in UITabBar in swift

前端 未结 4 799
傲寒
傲寒 2020-12-28 22:57

I\'m almost finished with a project and am working out the last few UI kinks. My app uses a tab bar to navigate and for aesthetic purposes I want the app to open on the last

4条回答
  •  醉话见心
    2020-12-28 23:31

    Just set the selectedIndex of the tabBarController. Something along these lines.

    var freshLaunch = true
    override func viewWillAppear(animated: Bool) {
         if freshLaunch == true {
             freshLaunch = false
             self.tabBarController.selectedIndex = 4 // 5th tab
         }
    }
    

提交回复
热议问题