Solely full removing of the gesture recognizer labored for me.
I wrapped it up right into a single modifier (to be added to the element view).
struct ContentView: View {
var physique: some View {
VStack {
...
)
.disableSwipeBack()
}
}
DisableSwipeBack.swift
import Basis
import SwiftUI
extension View {
func disableSwipeBack() -> some View {
self.background(
DisableSwipeBackView()
)
}
}
struct DisableSwipeBackView: UIViewControllerRepresentable {
typealias UIViewControllerType = DisableSwipeBackViewController
func makeUIViewController(context: Context) -> UIViewControllerType {
UIViewControllerType()
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
}
}
class DisableSwipeBackViewController: UIViewController {
override func didMove(toParent mum or dad: UIViewController?) {
tremendous.didMove(toParent: mum or dad)
if let mum or dad = mum or dad?.mum or dad,
let navigationController = mum or dad.navigationController,
let interactivePopGestureRecognizer = navigationController.interactivePopGestureRecognizer {
navigationController.view.removeGestureRecognizer(interactivePopGestureRecognizer)
}
}
}
You possibly can resolve the navigation controller with out third social gathering through the use of a
UIViewControllerRepresentable
within the SwiftUI hierarchy, then entry the mum or dad of its mum or dad.