以下のようにself.addChildViewController()を複数回実行すると、
FirstViewControllerからSecondViewControllerに遷移した状態になります。
(FirstViewControllerへは、self.navigationController?.popViewControllerAnimated(true) で戻ることができます。)
import Foundation
import UIKit
class NavigationController:UINavigationController {
required init?(coder: NSCoder) {
super.init(coder: coder)
let firstViewController = FirstViewController()
self.addChildViewController(firstViewController)
let secondViewController = SecondViewController()
self.addChildViewController(secondViewController)
}
}
import Foundation
import UIKit
class FirstViewController: UIViewController {
〜略〜
}
import Foundation
import UIKit
class SecondViewController:UIViewController{
var leftBarButton: UIBarButtonItem!
override func viewDidLoad() {
leftBarButton = UIBarButtonItem(title: "< Previous Page", style: .Plain, target: self, action: "tappedLeftBarButton")
self.navigationItem.leftBarButtonItem = leftBarButton
}
func tappedLeftBarButton() {
self.navigationController?.popViewControllerAnimated(true)
}
〜略〜
}


