Fist I’m sorry for my English
I’m starting my first project for iDevices, But I have a lot of issues
I’m create a TabBarController.swift class for customizing:
`class TabBarController: UITabBarController, UITabBarControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}
override func viewWillAppear(animated: Bool) {
let home = HomeController()
let service = ServiceViewController()
let home2 = Home2Controller()
let service2 = Service2ViewController()
let homeIcon = UITabBarItem(title: "Home", image: nil, selectedImage: nil)
let serviceIcon = UITabBarItem(title: "Service", image: nil, selectedImage: nil)
let homeIcon2 = UITabBarItem(title: "Home2", image: nil, selectedImage: nil)
let serviceIcon2 = UITabBarItem(title: "Service2", image: nil, selectedImage: nil)
home.tabBarItem = homeIcon
service.tabBarItem = serviceIcon
home2.tabBarItem = homeIcon
service2.tabBarItem = serviceIcon
let tabBarController = [home, service, home2, service2]
self.viewControllers = tabBarController
}
func tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool {
return true
}
} `
I made 4 ViewController.swift class like this:
import UIKit class HomeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = UIColor.greenColor() self.title = "Home" print("Home Page") / } }
in storyboard:
Storyboard Image:
Root: a tab tab controller
first row: 4 navigation controller
second row: 4 view controller
I set all view controllers identify inspect to self view controller class.
I set tabBarController identify inspect class to UITabBarController class.
my problem appear after running this app, I except to see this black/ gray/ green/ blue views, but I didn’t.
after some changes I found out that views I designed in storyboard will not showed.
So I made a navigationController class and set navigation controller identify inspector to this class and changed TabBarController class to work with navigationController class instead of view controllers. after running navigation appeared but still now view from storyboard!!!
I’m just confused! Why xCode dont understand connection between this views from storyboard ?!!
It’s gone take a lot of time If I defined all views in code.