解决 SwiftUI 中侧滑返回无效的问题

直接上代码

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

    public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        return viewControllers.count > 1
    }
}

SwiftUI 技术交流群

加我微信wr1204607318,拉你入群

参考

https://stackoverflow.com/questions/59234958/swiftui-navigationbarbackbuttonhidden-swipe-back-gesture

推荐

SwiftUI 自定义导航栏

你可能感兴趣的:(解决 SwiftUI 中侧滑返回无效的问题)