【iOS】Swipe与Pan区别分析

  By definition, a swipe gesture is necessarily also a pan gesture -- both involve translational movement of touch points. The difference is in the recognizer semantics: a pan recognizer looks for the beginning of translational movement and continues to report movement in any direction over time, while a swipe recognizer makes an instantaneous decision as to whether the user's touches moved linearly in the required direction. 

  根据定义,滑动手势也必然是平移手势 - 都涉及触摸点的平移运动。不同之处在于识别器语义:平移识别器查找平移运动的开始并继续报告随时间在任何方向上的移动,而滑动识别器立即决定用户的触摸是否在所需方向上线性移动。

  By default, no two recognizers will recognize the same gesture, so there's a conflict between pan and swipe. Most likely, your pan recognizer "wins" the conflict because its gesture is simpler / more general: A swipe is a pan but a pan may not be a swipe, so the pan recognizes first and excludes other recognizers.

  默认情况下,没有两个识别器会识别相同的手势,因此平移和滑动之间存在冲突。最有可能的是,你的pan识别器会赢得”冲突,因为它的手势更简单/更通用:滑动是一个平移但是平移可能不是一个滑动,所以平移首先识别并排除其他识别器。

  You should be able to resolve this conflict using the delegate method gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:, or perhaps without delegation by making the pan recognizer depend on the swipe recognizer with requireGestureRecognizerToFail:.

  您应该能够使用委托方法 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:来解决此冲突,或者通过使pan识别器依赖于滑动识别器带有 requireGestureRecognizerToFail:。

  With the conflict resolved, you should be able to simulate a one-finger swipe by quickly dragging the mouse. (Though as the mouse is more precise than your finger, it's a bit more finicky than doing the real thing on a device.) Two-finger pan/swipe can be done by holding the Option & Shift keys.

  解决冲突后,你应该可以模拟一根手指通过快速拖动鼠标滑动。 (虽然鼠标比手指更精确,但它比在设备上做真实的东西更加挑剔。)双手平移/滑动可以通过按住Option& Shift键。

posted @ 2019-11-17 10:17  Mr·Xu  阅读(813)  评论(0编辑  收藏  举报