title: How to disable a "gesture recognizer" (XMCircleGestureRecognizer)?
body: <p>For the app I'm building I'm using <a href="https://github.com/MichMich/XMCircleGestureRecognizer" rel="nofollow noreferrer">this class</a>, and, as I recognize other gestures such as taps, swipes or long press without using apple gesture recognizer (I've built my own as these from Apple are to accurate) I'd like to be able to disable the XMCircleGestureRecognizer, and just enable it when I need it. </p>
  
  <p>The problem is that when I'm calling it after some conditions, even if I lift my finger from the screen, and touch again the screen, it's still in the XMCircleGestureRecognizer, and never leave it. I've to kill the app and restart it.</p>
  
  <p>I'm not sure that providing some of my code is necessary but if needed, just tell me (it's 600 lines long so it's pretty hard to get only the part you need).</p>
  
  <p>Do you have any idea how I could do that ?
  Because I'm totally stuck on this point.</p>
  
  <p>Thanks a lot for the help !</p>
  
  <p>EDIT: </p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  var gesture: XMCircleGestureRecognizer?
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
      ascending = false
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
  }
  
  override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      gesture?.isEnabled = false
      super.touchesBegan(touches, with: event)
      for touch in touches{
          let point = touch.location(in: self.view)
          for (index,finger)  in fingers.enumerated() {
              if finger == nil {
                  fingers[index] = String(format: "%p", touch)
  
                  if (finger1.isEmpty){
                      finger1 = [point.x, point.y]
                  } else if (finger2.isEmpty){
                      finger2 = [point.x, point.y]
                  } else if (finger3.isEmpty){
                      finger3 = [point.x, point.y]
                  } else if (finger4.isEmpty){
                      finger4 = [point.x, point.y]
                  } else if (finger5.isEmpty){
                      finger5 = [point.x, point.y]
                  }
                  break
              }
          }
      }
  
      timer = Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(increaseValue), userInfo: nil, repeats: true)
      if ascending {
          ascending = false
      }
      else {
          ascending = true
      }
  }
  
  override func touchesMoved(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      super.touchesMoved(touches, with: event)
  
      for touch in touches {
          let point = touch.location(in: self.view)
          for (index,finger) in fingers.enumerated() {
              if let finger = finger, finger == String(format: "%p", touch) {
                  switch (index){
                  case 0 :
                      finger1 += [point.x, point.y]
                  case 1 :
                      finger2 += [point.x, point.y]
                  case 2 :
                      finger3 += [point.x, point.y]
                  case 3 :
                      finger4 += [point.x, point.y]
                  case 4 :
                      finger5 += [point.x, point.y]
                  default :
                      break
                  }
              }
          }
      }
  }
  
  override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      super.touchesEnded(touches, with: event)
      endTime = getCurrentMillis()
      gesture?.isEnabled = false
  
      for touch in touches {
          for (index,finger) in fingers.enumerated() {
              if let finger = finger, finger == String(format: "%p", touch) {
                  fingers[index] = nil
                  break
              }
          }
      }
  
      direction[0] = ""
      direction[1] = ""
      direction[2] = ""
      direction[3] = ""
      direction[4] = ""
  
      if finger1.count != 0 {
          direction[0] = GestureRecognizer(coordinates: finger1, index: 0)
      }
      if finger2.count != 0 {
          direction[1] = GestureRecognizer(coordinates: finger2, index: 1)
      }
      if finger3.count != 0 {
          direction[2] = GestureRecognizer(coordinates: finger3, index: 2)
      }
      if finger4.count != 0 {
          direction[3] = GestureRecognizer(coordinates: finger4, index: 3)
      }
      if finger5.count != 0 {
          direction[4] = GestureRecognizer(coordinates: finger5, index: 4)
      }
  
  if Int64(endTime - startTime) &lt; 400 {
  // HERE I TEST MY GESTURES
  }
  }
  
  func increaseValue() -&gt; Int {
  // HERE I TEST FOR LONG PRESS
  else if !finger1.isEmpty &amp;&amp; abs(finger1[finger1.count - 2] - finger1[0]) &gt;= 40 &amp;&amp; abs(finger1[1] - finger1[finger1.count - 1]) &gt;= 40 {
  
          gesture = XMCircleGestureRecognizer(midPoint: self.view.center, target: self, action: #selector(ViewController.rotateGesture(recognizer:)))
          self.view.addGestureRecognizer(gesture!)
  
      }
      return value
  }
  
  func rotateGesture(recognizer:XMCircleGestureRecognizer)
  {
      StatusLabel.text = ""
  
      if let rotation = recognizer.rotation {
          currentValue += rotation.degrees / 360 * 100
          StatusLabel.text = StatusLabel.text! + String(format:"Value: %.2f%%", currentValue)
      }
  
      if let angle = recognizer.angle {
          StatusLabel.text = StatusLabel.text! + "\n" + String(format:"Angle: %.2f%", angle.degrees)
      }
  
      if let distance = recognizer.distance {
          StatusLabel.text = StatusLabel.text! + "\n" + String(format:"Distance: %.0f%", distance)
      }
  
  }
  </code></pre>