简体   繁体   English

检测用户结束的触摸屏

[英]Detecting user ended touching screen

in my app i'm able to detect a touch by connecting the view to an action touch down event. 在我的应用中,我可以通过将视图连接到动作按下事件来检测触摸。 However, i want to be able to detect that the user lifted his finger off screen. 但是,我希望能够检测到用户将手指抬离屏幕。 am i able to do that? 我能做到吗?

Edit: sorry for the short post. 编辑:对短文表示抱歉。 actually i have no hint how to do that or even to try to do that! 实际上,我没有任何提示该怎么做甚至尝试做!

Well, that depends on where you're trying to track the touch removal. 好吧,这取决于您尝试跟踪触摸移除的位置。 If for example, you're using a button and you've already linked an action to touchDown, you can simply link another action for the buttons control event touch up inside/outside. 例如,如果您使用的是按钮,并且已经将一个动作链接到touchDown,则可以简单地将另一个动作链接到按钮上,以控制事件在内部/外部的触摸。

If you're interested in tracking that touches ended on the entire screen, you can use -touchesEnded: withEvent: . 如果您想跟踪整个屏幕上的触摸结束,则可以使用-touchesEnded: withEvent:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
}

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

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