1

I can't set the 'enabled' property with gesture recognizers. I tried creating recognizers both programmatically and by adding an @IBAction in Xcode and connecting it by control drag to the code.

I try to use properties like this:

swipeUpOccurred(swipeUp: UISwipeGestureRecognizer).enabled = false

But it is showing error:

Value of type '(UISwipeGestureRecognizer) ->' does not have member 'enabled'

Nirav D
  • 71,513
  • 12
  • 161
  • 183
Anton Platonov
  • 379
  • 4
  • 15

3 Answers3

5

You are trying to set the isEnabled on the action of UIGestureRecognizer. Instead of that you need to create the Outlet of UIGestureRecognizer if you want to access it inside your ViewController, so create one Outlet of that gesture with its specific type then set isEnabled property to true/false when ever you need to enable/disabled it.

@IBOutlet var swipeGest: UISwipeGestureRecognizer!

Now use isEnabled property with it.

self.swipeGest.isEnabled = false
Nirav D
  • 71,513
  • 12
  • 161
  • 183
0

It was renamed. Try isEnabled instead.

swipeUpOccurred(swipeUp: UISwipeGestureRecognizer).isEnabled = false
Vladyslav Zavalykhatko
  • 15,202
  • 8
  • 65
  • 100
0

isEnabled should be used instead

Orest Savchak
  • 4,529
  • 1
  • 18
  • 27