[ad_1]
I have a two ViewControllers A and B and a SwiftUI view, navigating from “A” controller to SwiftUIview inside this implemented NavigationLink to navigate -> “B” controller. Trying to pop back to Controller “A” from “B” skipping SwiftUI in between
below solution are not working
.onDisappear
tried something like this presentationMode.wrappedValue.dismiss()
On A ViewController
func integrateSwiftUIView() {
let hostingController = UIHostingController(rootView: swiftUIView)
addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
let constraints = [
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.leftAnchor.constraint(equalTo: view.leftAnchor),
view.bottomAnchor.constraint(equalTo: hostingController.view.bottomAnchor),
view.rightAnchor.constraint(equalTo: hostingController.view.rightAnchor)
]
NSLayoutConstraint.activate(constraints)
hostingController.didMove(toParent: self)
}
On integrateSwiftUIView using UIViewControllerRepresentable to reach BViewController
NavigationLink(isActive: $isPresented) {
LaunchBViewController()
}) {
}
- Pop back directly to AViewController from BViewController
- Dismiss SwiftUIView
[ad_2]
Source link