Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swipe back to dismiss is broken (but there's a fix) #14

Open
jenspots opened this issue Jul 20, 2022 · 2 comments
Open

Swipe back to dismiss is broken (but there's a fix) #14

jenspots opened this issue Jul 20, 2022 · 2 comments

Comments

@jenspots
Copy link

Hello. Thanks for making this handy library. I've noticed that on modern iOS versions the swipe back functionality is broken despite the fact that an old fix is in place. Luckily, I found a solution by implementing the following extension.

extension UINavigationController {
    override open func viewDidLoad() {
        super.viewDidLoad()
        interactivePopGestureRecognizer?.delegate = nil
    }
}

That's it! View+hideNavigationBarWithoutLosingSwipeBack.swift and View+hideNavigationBarWithoutLosingSwipeBack.swift are no longer required using this method.

If you wish I could open a pull request. Regardless I hope this may be useful to someone in the future.

@jenspots
Copy link
Author

Extending UINavigationController globally causes a lot of side effects, but using SwiftUI Introspect might get rid of most.

SomeView {
    ...
}
.introspectNavigationController { view in
    view.interactivePopGestureRecognizer?.delegate = nil
}

I'll keep looking into this.

@kevanloy
Copy link

Not sure if anyone is using this given the lack of updates, but I got it working doing this

 .simultaneousGesture(
                DragGesture()
                    .onEnded { value in
                        // Detect swipe from the left edge for back navigation
                        if value.translation.width > 100 && value.startLocation.x < 20 {
                            presentationMode.wrappedValue.dismiss()
                        }
                    }
            )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants