James Dunay
James Dunay

Reputation: 2724

Detect when finger is dragged inside object (iOS touch)

I know I can use UIControlEventTouchDragEnter in order to tell when I have touched a button dragged my touch outside its bounds and then re-entered those bounds. However I was wondering would it be possible to touch the screen, not on a button, and detect when I have dragged over/inside that button?

Also could someone tell me the difference between UIControlEventTouchDragExit UIControlEventTouchDragOutside

Thanks!

Upvotes: 1

Views: 1390

Answers (1)

Ole Begemann
Ole Begemann

Reputation: 135548

  1. You would have to observe touch events on the button's superview and whenever the user's fingers move, call hitTest:withEvent: to check whether the touch coordinates lie on top of the button.

  2. I believe the difference between UIControlEventTouchDragExit and UIControlEventTouchDragOutside is this: when the finger moves from inside the control to the outside, UIControlEventTouchDragExit fires once. Then, as long as the finger remains outside, UIControlEventTouchDragOutside fires on each move. But you should test this yourself.

Upvotes: 2

Related Questions