Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIControlEventTouchDragEnter doesn't seem to work for catching a tap that slides into a control

I wanted to allow for a method to get called, if a finger was dragged from outside into the bounds of a control. I thought UIControlEventTouchDragEnter would do it, but it doesn't seem to. Does anyone know if there is a way to trigger an action based on a tap sliding into a control?

This is what I was trying, but got no calls to my -fingerSlidIn:

[aButton addTarget:self action:@selector(fingerSlidIn:withEvent: ) forControlEvents: UIControlEventTouchDragEnter];

Thanks!

like image 468
mahboudz Avatar asked Nov 23 '25 12:11

mahboudz


1 Answers

This is by design. All events belonging to a continuous touch (from touch down until touch up) go to the view that received the first touch down event. So you will never receive a UIControlEventTouchDragEnter unless the user moved the finger away from the control and back.

To do what you want, you would have to capture the touches on the control's container view and determine manually when the touch coordinates enter your control's frame rect (possibly by calling pointInside:withEvent: for every touch you receive).

like image 64
Ole Begemann Avatar answered Nov 26 '25 17:11

Ole Begemann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!