如何将UIViewController调用到SwiftUI View

时间:2019-11-15 19:26:31

标签: swiftui

我试图学习SwiftUI。尝试实现SwiftUI代码。我不清楚。请任何人帮助我。

1)任何视图控制器到其他视图控制器。没问题。

让vc = viewController.init(nibName:“ VCNibName”,捆绑包:nil) self.navigationController?.pushViewController(vc,animation:true)

让newViewController = storyBoard.instantiateViewController(withIdentifier:“ VCIdentifier”) self.navigationController?.pushViewController(newViewController,animation:true)

2)SwiftUI视图的任何视图控制器。 如何将SwiftUIView推送到navigationController?

1 个答案:

答案 0 :(得分:0)

使用UIHostingController包装您的视图

let hostingController = UIHostingController(rootView: MySwiftUIView())
self.navigationController?.pushViewController(hostingController, animated: true)