Good day. There is a difficulty in setting up the Tab Bar Controller, the essence of the problem is that when you start the program, which of the several views will be started is determined automatically (there is an algorithm for choosing), but how to implement a simple launch of the view is unknown without any presses.
2 answers
To programmatically switch between the view in the tab bar controller, there are two methods selectedViewController and selectedIndex:
you can either specify which controller should become active (if you transfer a controller that is not included in the array of controllers of a given tab bar, nothing will happen)
tabbar.selectedViewController = myViewController either indicate the index of the new controller
tabbar.selectedIndex = 1 |
Inside the viewWillApper method viewWillApper write
self.selectedViewController = self.viewControllers![newIndex] as! UIViewController newIndex - the index of the controller that you want to appear first
|
selectedViewControllerandselectedIndex. call which one you like immediately on launching the application or in the first controller'sviewDidLoad. - Max Mikheyenko