UINavigationController Interactive Pop Gesture Not Working?

前端 未结 10 1437
你的背包
你的背包 2020-12-13 10:02

So I have a navigation controller in my built for iOS 7 app. The titleView is visible, as well as the back button and navigation bar its self. For some reason, the interac

10条回答
  •  [愿得一人]
    2020-12-13 10:34

    My answer is based on Eneko's answer but uses only an extension on UINavigationController and works in Swift 5:

    extension UINavigationController: UIGestureRecognizerDelegate {
    
        override open func viewDidLoad() {
            super.viewDidLoad()
            interactivePopGestureRecognizer?.delegate = self
        }
    
        public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
            return viewControllers.count > 1
        }
    }
    

提交回复
热议问题