简体   繁体   English

UIControlEventTouchDragEnter似乎不适用于捕获滑入控件的水龙头

[英]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. 我以为UIControlEventTouchDragEnter会这样做,但它似乎没有。 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: 这就是我的尝试,但没有调用我的-fingerSlidIn:

[aButton addTarget:self action:@selector(fingerSlidIn:withEvent: ) forControlEvents: UIControlEventTouchDragEnter]; [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. 因此,除非用户将手指从控件移开并返回,否则您将永远不会收到UIControlEventTouchDragEnter。

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). 要做你想做的事,你必须捕获控件容器视图上的触摸,并在触摸坐标进入控件的框架rect时手动确定(可能通过调用pointInside:withEvent:为你收到的每次触摸)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM