Anton Platonov
Anton Platonov

Reputation: 389

How to set 'enabled' property for gesture recognizers in Swift 3

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'

Upvotes: 1

Views: 878

Answers (3)

Nirav D
Nirav D

Reputation: 72410

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

Upvotes: 5

Vladyslav Zavalykhatko
Vladyslav Zavalykhatko

Reputation: 17364

It was renamed. Try isEnabled instead.

swipeUpOccurred(swipeUp: UISwipeGestureRecognizer).isEnabled = false

Upvotes: 0

Orest Savchak
Orest Savchak

Reputation: 4569

isEnabled should be used instead

Upvotes: 0

Related Questions