开发者

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 开发者_StackOverflow社区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!


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜