【swift】UITabBarController・UINavigationControllerにタイトルをつける方法メモ

今回はまった状況としては、UITabBarController配下にUINavigationControllerを並べた場合です。

TabBarController.swift

class TabBarController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        uinavigationcontroller1 = UINavigationController()
        uinavigationcontroller2 = UINavigationController()
        uinavigationcontroller3 = UINavigationController()

        var tabs = NSArray(objects: uinavigationcontroller1, uinavigationcontroller2, uinavigationcontroller3)
        self.setViewControllers(tabs as [AnyObject], animated: true)

        // ★ここで各タブのタイトルを設定
        uinavigationcontroller1.tabBarItem.title = "タブ1"
        uinavigationcontroller2.tabBarItem.title = "タブ2"
        uinavigationcontroller3.tabBarItem.title = "タブ3"
    }
}

各ViewController

class SampleViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        // ★ここでナビゲーションバーのタイトルを設定
        self.navigationItem.title = "タイトル"
    }
}

最初、各ViewControllerのタイトルは「self.title="***"」の形で実装していたのですが、この値を変えるとViewControllerのtitleがタブのタイトルとなってしまいました。

細かいことなのですがはまったのでメモしておきます
以上です