스와이프(Swipe)로 뒤로가기 처리

iOS 7 이후부터 지원

viewWillAppear에서 네비게이션 컨트롤의 interactivePopGestureRecognizer delegate를 설정해주면 된다.

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    self.navigationController?.interactivePopGestureRecognizer?.delegate = self
}

extension UIViewController : UIGestureRecognizerDelegate {
    public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        return true
    }
}


Posted by 까칠코더