【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. ui

  根據定義,滑動手勢也必然是平移手勢 - 都涉及觸摸點的平移運動。不一樣之處在於識別器語義:平移識別器查找平移運動的開始並繼續報告隨時間在任何方向上的移動,而滑動識別器當即決定用戶的觸摸是否在所需方向上線性移動。this

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

  默認狀況下,沒有兩個識別器會識別相同的手勢,所以平移和滑動之間存在衝突。最有可能的是,你的pan識別器會贏得」衝突,由於它的手勢更簡單/更通用:滑動是一個平移可是平移可能不是一個滑動,因此平移首先識別並排除其餘識別器。ci

  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:.it

  您應該可以使用委託方法 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:來解決此衝突,或者經過使pan識別器依賴於滑動識別器帶有 requireGestureRecognizerToFail:。io

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

  解決衝突後,你應該能夠模擬一根手指經過快速拖動鼠標滑動。 (雖然鼠標比手指更精確,但它比在設備上作真實的東西更加挑剔。)雙手平移/滑動能夠經過按住Option& Shift鍵。方法

相關文章
相關標籤/搜索