我需要使用带有后退按钮的 UINavigation 从 SwiftUI 打开 UIViewController。
目前,我已经通过 ViewControllerRepresentable 和 NavigationLink 实现了这个,它的工作原理,但是我有两个导航 SwiftUI(带有后退按钮的 NavigationLink)和没有后退按钮的默认 UINavigation,我想执行让我的默认 UINavigation 带有后退按钮并隐藏SwiftUI(NavigationLink) 导航。
struct UIKitVc : UIViewControllerRepresentable {
let navigationController = UINavigationController()
func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {
}
func makeUIViewController(context: Context) -> UINavigationController {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "SearchResult") as! SearchResultViewController
self.navigationController.addChild(viewController)
return self.navigationController
}
}
NavigationLink(destination: UIKitVc(){}
先感谢您。