https://stackoverflow.com/questions/18946302/uinavigationcontroller-interactive-pop-gesture-not-working

UINavigationController에 붙어있는 ViewController이지만백제스쳐가 동작하지 않는 경우가 왕왕있다.

 

해당 문제는 제스쳐 이벤트 끼리의 충돌문제인것으로 보인다이때 네비게이션 제스쳐를 하나의 UINavigationController 내부의 viewControllers개수가 하나보다 많을때만 동작하도록 지정해주는 걸 달아주면 이상하게도 동작을 잘한다.

 

해당 소스는 상단 스택오버플로우의 답에 달린 코드이다.

class NavigationController: UINavigationController, UIGestureRecognizerDelegate {

    /// Custom back buttons disable the interactive pop animation
    /// To enable it back we set the recognizer to `self`
    override func viewDidLoad() {
        super.viewDidLoad()
        interactivePopGestureRecognizer?.delegate = self
    }

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

}

+ Recent posts