UINavigationController
右滑popVC的手势.
完美使用:
创建一个继承
UINavigationController
自己的NavigationController 遵守协议: UIGestureRecognizerDelegate, UINavigationControllerDelegate
1.viewDidLoad
self.interactivePopGestureRecognizer?.delegate = self
self.delegate = self
2.重写push
override func pushViewController(viewController: UIViewController, animated: Bool) {
if self.viewControllers.count > 0 {
self.interactivePopGestureRecognizer?.enabled = true
}
super.pushViewController(viewController, animated: true)
}
func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool) {
if navigationController.viewControllers.count == 1 {
self.interactivePopGestureRecognizer?.enabled = false
}
}
大功告成..