iOS开发:解决右滑返回上一页功能失效

iOS7以后,默认支持右滑返回上一页,但是,当隐藏navigationBar或是自定义返回按钮时,右滑返回就会失效。解决方法,自己实现interactivePopGestureRecognizer的delegate
viewDidLoad:

 navigationController?.interactivePopGestureRecognizer!.delegate =  self ;

实现UIGestureRecognizerDelegate定义的方法:

    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        if (navigationController?.viewControllers.count <= 1 ) {
            return false;
        }
        return true;
    }

© 2016, 冰冻鱼. 请尊重作者劳动成果,复制转载保留本站链接! 应用开发笔记