I have a SwiftUI app that has three levels:
- Main List (SwiftUI NavigationView)
- Secondary List (SwiftUI NavigationView)
- An UIViewControllerRepresentable
In my secondary list I have
NavigationLink(destination: ARView(museum: self.museum)) {
Image(systemName: "camera.viewfinder")
})
And then in the UIViewControllerRepresentable I have
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>) {
}
}
The back button that appears should go back to the Secondary List, but instead it goes back to the Main List.
question from:
https://stackoverflow.com/questions/66065702/back-button-in-uiviewcontrollerrepresentable-goes-to-root-view-instead-of-going 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…