使用不跟随拇指的屏幕边缘平移手势识别器的弹出视图控制器

Pop view controller using Screen edge pan gesture recogniser not following the thumb

一旦我添加了自定义栏导航栏按钮项目,我就失去了使用默认功能返回的能力。我希望能够使用 "swipe from edge" 返回。

我已经添加了 Edge Pan Gesture Recogniser 并将其连接到@IBAction,但是一旦识别出平移手势,就会完全消除操作。

当前视图不会随着我的拇指慢慢移动(如在其他应用程序中看到的那样),而是以预定义的动画移出。

如何使用 Edge Pan Gesture Recogniser 制作跟随拇指移动的动画?

@IBAction func edgeSwipe(sender: AnyObject) {
    navigationController?.popViewControllerAnimated(true)
}

无需添加 Edge Pan Gesture Recogniser。按照@beyowulf 的建议,我已经能够实现滑动返回功能,其行为方式与默认系统实现相同 - 当我滑动它以关闭它时,视图边缘跟随我的拇指。

所以我从情节提要中删除了 ScreenEdge Pan Gesture Recogniser,还删除了相关的 @IBAction

我已经将我的第一个视图控制器设为 interactivePopGestureRecognizer 的委托。这是代码:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.interactivePopGestureRecognizer?.delegate = self
    }
}

extension ViewController: UIGestureRecognizerDelegate {

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