swift 恢复 滑动返回 手势

前端之家收集整理的这篇文章主要介绍了swift 恢复 滑动返回 手势前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

自定义导航控制器 或者 自定义返回按键的时候,滑动返回的手势经常会失效. 下面是解决方法

创建一个 UINavigationController 控制器

设置两个代理UIGestureRecognizerDelegate,UINavigationControllerDelegate

重写父类的两个方法

override func viewDidLoad() {
         super.viewDidLoad()
        self.interactivePopGestureRecognizer.delegate = self
    }
    override func pushViewController(viewController: UIViewController,animated: Bool) {
        super.pushViewController(viewController,animated: animated)
        self.interactivePopGestureRecognizer.enabled = true

    }
原文链接:https://www.f2er.com/swift/326556.html

猜你在找的Swift相关文章