Post

Replies

Boosts

Views

Activity

Disable SwiftUI NavigationView Swipe
I am using SwiftUI NavigationView to navigate. I cant find how can i disable swipe from the leftmost part of the screen for navigation bar. Im tried this way , but it doesn't work for me: struct DisableBackSwipeGestureView: UIViewControllerRepresentable { typealias UIViewControllerType = UINavigationController func makeUIViewController(context: Context) -> UINavigationController { DisableSwipeBackViewController().navigationController ?? UINavigationController() } func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {} func makeCoordinator() -> Coordinator { return Coordinator() } class Coordinator: NSObject, UIGestureRecognizerDelegate { func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { return false } } } final class DisableSwipeBackViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if let navigationController = self.navigationController { if let interactivePopGestureRecognizer = navigationController.interactivePopGestureRecognizer { interactivePopGestureRecognizer.delegate = self interactivePopGestureRecognizer.isEnabled = false } } } } extension DisableSwipeBackViewController: UIGestureRecognizerDelegate { func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { return false } } extension View { func disableSwipeBackGesture() -> some View { self.modifier(DisableSwipeBackGesture()) } } Is there a way to disable this feature in swiftui?
0
0
83
Sep ’24