2015-08-04 6 views
0

Иам делает UITabBarController в коде, это мой кодINIT UITabBarController в коде

 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() 

, который я называю в ViewDidLoad в моей ViewController которые подлодки UITabBarController. На моей вкладке не отображаются все названия элементов tabBar, laso показывает их неправильно (зеленый backGround для SearchStamViewController не SearchStamViewController !!)

что не так ??!

enter image description here

ответ

0

Я обновил код

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() 
+0

что вы изменили?! – user3703910

+0

Вы добавили все tabBarItem только на один контроллер recordsVC. –

0

я узнал проблему, я не musn't начать новую UITabBarItem вместо

var recordsVC = SearchStamViewController() 
recordsVC.tabBarItem.title = "Records"