user6820041
user6820041

Reputation: 1223

Adding gestures to a draggable view? Swift

I've got buttons on my view that are draggable using touches began/moved/ended. I want to add a tapped and doubletapped actions for my buttons. Once I switch my button's class to UIButton the action I've created works, but once I change it back to DraggableView the actions stop being called because I guess touchesBegan overrides any other touches on the view.

Is there a good way to do this?

Upvotes: 0

Views: 137

Answers (1)

Sachin Amrale
Sachin Amrale

Reputation: 297

First of all you have to implement UITapGestureRecogizer delegate in your class and add following line of code.

let tap = UITapGestureRecognizer(target: self, action: "handleTap:")
tap.delegate = self
tap.numberOfTapsRequired = 1
yourButton.addGestureRecognizer(tap)

Hope this helps.

Upvotes: 1

Related Questions