【发布时间】:2021-12-24 18:00:35
【问题描述】:
我正在尝试创建 Coordinator 以从 Screen1 导航到 Screen2
这里是 UIKit 的例子
class Coordinator: AbstractCoordinator {
var navigationController: UINavigationController?
func goToHomeScreen() {
navigationController?.pushViewController(HomeViewController(coordinator: self), animated: true)
}
func start() -> UIViewController {
self.navigationController = UINavigationController(rootViewController: LoginViewController(coordinator: self))
return navigationController!
}
}
当我们使用模块化编程时,这个 Coordinator 非常有用。我想在 SwiftUI 中做同样的事情
我知道我们必须使用 NavigationView、NavigationLink 但我不明白我应该如何在 Coordinator 中使用
谁能告诉我该怎么做?
【问题讨论】: