我有一个 SwiftUI 应用程序,它具有三个级别:
- 主列表(SwiftUI NavigationView)
- 二级列表(SwiftUI NavigationView)
- 一个 UIViewControllerRepresentable
在我的二级列表中,我有
NavigationLink(destination: ARView(museum: self.museum)) {
Image(systemName: "camera.viewfinder")
})
然后在 UIViewControllerRepresentable 我有
struct ARView: UIViewControllerRepresentable {
var museum:Museum?
var work:Work?
func makeUIViewController(context: UIViewControllerRepresentableContext<ARView>) -> UIViewController {
let ARVC = ARViewController(nibName: "ARViewController", bundle: .main)
if let museum = museum {
ARVC.visitedMuseum = museum
ARVC.ARExperience = false
LoggingSystem.push(eventLog: ["event":"AR opened","museum":ARVC.visitedMuseum.name], verbose: false)
}
if let work = work {
ARVC.visitedWork = work
ARVC.VRonly = true
LoggingSystem.push(eventLog: ["event":"Work selected","work":ARVC.visitedWork.name], verbose: false)
}
return ARVC
}
func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext<ARView>) {
}
}
出现的后退按钮应该返回到辅助列表,但它会返回到主列表。