How to disable Swipe Gesture recognizer when a button is pressed?

901 views Asked by At

I set up the recognizer like this:

    @IBAction func changeSeq(_ recognizer: UISwipeGestureRecognizer) {

    if (recognizer.direction == UISwipeGestureRecognizerDirection.left)
    {
    print ("nice")
    }
}

I need it disabled when the start button is pressed and enabled again when the pause is triggered. I don't want to disable all user interaction. How do I handle the swipe specifically?

2

There are 2 answers

1
Duncan C On BEST ANSWER

In your start button IBAction code, set the gesture recognizer's enabled property to false, and in the pause button's IBAction, set enabled = true.

That's cleaner than setting the delegate to nil.

1
Sivajee Battina On

If you are using swipe gesture delegates, change to nil and self according to button presses.