I am refactoring my codes and want to give Coordinators a try.
However, I am not quite comfortable with UINavigationController
in charge, cause it creates a Back button on child coordinates as well as an unwanted top bar which I don’t want.
Is there anyway I could use ordinary UIViewController
instead of UINavigationController
?
P.S : it is a sample code I found [Here][1]
protocol Coordinator { func start() }
protocol FlowACoordinatable { var coordinator: FlowACoordinator }
class FlowACoordinator: Coordinator {
private var navigationController: UINavigationController
private var firstVC: FirstViewController
private var secondVC: SecondViewController
init(navigationController: UINavigationController) {
self.navigationController = navigationController
}
func start() { ... }
func present(_ viewController: (FlowACoordinatable & UIViewController)) {
viewController.coordinator = self
self.navigationController.pushViewController(viewController, animated: true)
}
...
}
class FirstViewController: UIViewController, FlowACoordinatable {
var coordinator: FlowACoordinator?
func buttonTapped() {
self.coordinator?.goToNextStep()
}
}
Answering my own question...
Coordinators architecture is based on UINavigationController
and can not be replaced by UIViewController
.
But still, it is possible to hide the buttom bar pane using Object Inspection and check Hide buttom bar... or do it by code.