這個(gè)跟UINavigationController有什么區(qū)別呢?
其實(shí)就是對(duì)UINavigationController的封裝控制
let childNavigationController: UINavigationController
繼續(xù)看它是如何被構(gòu)造的
init(rootViewController: UIViewController = UIViewController()) {
self.rootViewController = rootViewController
self.childNavigationController = UINavigationController(rootViewController: rootViewController)
super.init(nibName: nil, bundle: nil)
}
init(
navigationBarClass: Swift.AnyClass?,
toolbarClass: Swift.AnyClass?
) {
self.rootViewController = UIViewController()
self.childNavigationController = UINavigationController(
navigationBarClass: navigationBarClass,
toolbarClass: toolbarClass
)
super.init(nibName: nil, bundle: nil)
}
功能舉個(gè)例子:
- 如何Push一個(gè)Coordinator
func pushCoordinator(coordinator: RootCoordinator, animated: Bool) {
//用dictionary記錄vc于coordinator的關(guān)系:
viewControllersToChildCoordinators[coordinator.rootViewController] = coordinator
//
pushViewController(coordinator.rootViewController, animated: animated)
}
func pushViewController(_ viewController: UIViewController, animated: Bool) {
childNavigationController.pushViewController(viewController, animated: animated)
}