简体   繁体   English

iOS:检测touchEnded是否来自滑动屏幕或抬起手指?

[英]iOS: Detect if touchEnded comes from sliding off screen or lifting finger?

In iOS is there any way to tell, when the touch ends, if it ended by sliding off the screen or if the user lifted his finger? 在iOS中有什么方法可以告诉,当触摸结束时,是否通过滑出屏幕或用户抬起手指而结束?

I don't know why, but I expected the touch to be cancelled when this happened, but it is not. 我不知道为什么,但我预计在发生这种情况时会取消触摸,但事实并非如此。

Thanks. 谢谢。

This is standard iOS behavior, you may see it in any Apple's app. 这是标准的iOS行为,您可以在任何Apple的应用程序中看到它。

You may check if touch ended at the end of screen and treat it as "cancel sliding", but user might be wanting to slide this far. 您可以检查触摸是否在屏幕末尾结束并将其视为“取消滑动”,但用户可能想要滑动这么远。

My advice is accept it, because, as I said before, it's standard behavior, and Apple tells us to stick to it - users expect standard behavior. 我的建议是接受它,因为,正如我之前所说,它是标准行为,Apple告诉我们坚持它 - 用户期望标准行为。

Only through deduction. 只能通过演绎。 If the finger was moving towards the edge of the screen and then the touch ends near that edge, you can be relatively certain that the finger indeed slid off the screen. 如果手指朝向屏幕边缘移动然后触摸在该边缘附近结束,则可以相对确定手指确实从屏幕滑落。 If it wasn't moving immediately before the touch ended, the user probably just lifted their finger. 如果在触摸结束之前没有立即移动,则用户可能只是举起手指。

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

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