这个跟UINavigationController有什么区别呢?
其实就是对UINavigationController的封装控制
let childNavigationController: UINavigationController
继续看它是如何被构造的
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)
}
功能举个例子:
- 如何Push一个Coordinator
func pushCoordinator(coordinator: RootCoordinator, animated: Bool) {
//用dictionary记录vc于coordinator的关系:
viewControllersToChildCoordinators[coordinator.rootViewController] = coordinator
//
pushViewController(coordinator.rootViewController, animated: animated)
}
func pushViewController(_ viewController: UIViewController, animated: Bool) {
childNavigationController.pushViewController(viewController, animated: animated)
}