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.

  • it is possible in more detail what exactly should be received. - Max Mikheyenko
  • need to get a program that, under different circumstances, starts another View - Bohdan Lashta
  • In the sense of changing the selected tabbarview from UITabBarController? - Max Mikheyenko
  • There is a TavBarController, there are several views whose icons are on TabBar-e, by default the program starts on the first tab, I also need to configure this "default" - Bohdan Lashta
  • UITabBarController has two methods selectedViewController and selectedIndex . call which one you like immediately on launching the application or in the first controller's viewDidLoad . - Max Mikheyenko

2 answers 2

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