InteractivePopGestureRecognizer causing app freezing

前端 未结 9 1807
再見小時候
再見小時候 2021-01-31 10:29

In my app I have different controllers. When I push controller1 to navigation controller and swipe to back, all works good. But, if I push navigation controller1, and into contr

9条回答
  •  旧巷少年郎
    2021-01-31 11:03

    I had problem when swipe back on first controller and then tap on tableViewCell, I think that force touch swipe from edge is registering swipe back before switches app, sometimes UI get stuck, sometimes when I swipe back it starts entering on destination controller. I solved problem with this extension, it worked for me and it is simple solution. Swift 4.2

    extension UINavigationController:UINavigationControllerDelegate {
    
        open override func viewDidLoad() {
            super.viewDidLoad()
            self.delegate = self
        }
    
        public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
            if responds(to: #selector(getter: self.interactivePopGestureRecognizer)) {
                if viewControllers.count > 1 {
                    interactivePopGestureRecognizer?.isEnabled = true
                } else {
                    interactivePopGestureRecognizer?.isEnabled = false
                }
            }
        }
    }
    

提交回复
热议问题