0

Iam making a UITabBarController in code , this is my code

        var recordsVC = SearchStamViewController()
    recordsVC.tabBarItem = UITabBarItem(title: "Records", image: nil, selectedImage: nil)

    var stationsVC = StationsSeachViewController()
    recordsVC.tabBarItem = UITabBarItem(title: "stations", image: nil, selectedImage: nil)

    var peopleVC = PeopleSearchViewController()
    recordsVC.tabBarItem = UITabBarItem(title: "people", image: nil, selectedImage: nil)



    //self.tabBarController?.setViewControllers([stationsVC , recordsVC], animated: true)

    self.setViewControllers([recordsVC  , peopleVC , stationsVC], animated: true)
    self.selectedIndex = 1
    self.view.backgroundColor = UIColor.whiteColor()

which I call in ViewDidLoad in my viewController which subs UITabBarController . my tabbar doesn't show all the tabBar items titles , laso it shows them at a wrong way (the green backGround is for SearchStamViewController not SearchStamViewController !!)

what's wrong ??!

enter image description here

user3703910
  • 624
  • 1
  • 5
  • 25

2 Answers2

0

I have updated your code

var recordsVC = SearchStamViewController()
recordsVC.tabBarItem = UITabBarItem(title: "Records", image: nil, selectedImage: nil)

var stationsVC = StationsSeachViewController()
stationsVC.tabBarItem = UITabBarItem(title: "stations", image: nil, selectedImage: nil)

var peopleVC = PeopleSearchViewController()
peopleVC.tabBarItem = UITabBarItem(title: "people", image: nil, selectedImage: nil)

self.setViewControllers([recordsVC  , peopleVC , stationsVC], animated: true)
self.selectedIndex = 1
self.view.backgroundColor = UIColor.whiteColor()
Ashish P.
  • 848
  • 5
  • 12
0

I found out the problem , I musn't not start a new UITabBarItem instead

var recordsVC = SearchStamViewController()
recordsVC.tabBarItem.title = "Records"
user3703910
  • 624
  • 1
  • 5
  • 25