nerdsupremacist / FancyScrollView

A SwiftUI ScrollView Designed to imitate the App Store and Apple Music ScrollViews (with or without a Parallax Header)
MIT License
975 stars 55 forks source link

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

Open jenspots opened 2 years ago

jenspots commented 2 years ago

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 commented 2 years ago

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.