Andrej Andrej - 6 months ago 23
Swift Question

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

As soon as I've added custom bar navigation bar button item I've lost the ability to use the default function to go back. I'd like to have the ability to use "swipe from edge" to go back.

I've added the Edge Pan Gesture Recogniser and connected it to @IBAction, but the dismissing action happens completely as soon as the pan gesture is recognised.

Instead of slowly following my thumb (as seen in other apps), the current view moves out with predefined animation.

How to make the animation following my thumb using Edge Pan Gesture Recogniser?

@IBAction func edgeSwipe(sender: AnyObject) {

enter image description here


There's no need to add Edge Pan Gesture Recogniser. Following @beyowulf's suggestions I've been able to implement the swipe to go back feature that behaves the same way as the default system implementation does - the views edge follows my thumb as I swipe it to dismiss it.

So I've removed the ScreenEdge Pan Gesture Recogniser from the storyboard and also removed the related @IBAction.

I've made my first view controller to be the delegate for interactivePopGestureRecognizer. Here's the code:

class ViewController: UIViewController {

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

extension ViewController: UIGestureRecognizerDelegate {

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