UIButton和Swipe Gesture [英] UIButton and Swipe Gesture
问题描述
我有一个 UIView
,每边有两个 UIButton
,左边和右边是 UIImageView
位于中心。点击任一按钮都会改变 UIImageView
,这样可行。我希望能够刷过 UIView
,并且它会更改 UIImageView
。现在,您必须在 UIImageView
上滑动,因为 UIButton
正在捕获输入。
I have a UIView
with two UIButton
s on each side (left and right) and a UIImageView
in the center. A tap on either button will change the UIImageView
and that works. I want the ability swipe across the UIView
as well and it change UIImageView
. Right now, you have to swipe on the UIImageView
itself since the UIButton
s are catching the input.
我希望能够在包含 UIView
的任何地方执行滑动,并执行转换。有没有办法转发触摸事件,以便滑动可以触发一个动作,但任何其他触摸转发到正确的子视图?
I'd like to be able to perform a swipe anywhere on the containing UIView
and it performs the transition. Is there a way to forward touch events such that a swipe can trigger an action, but any other touch is forwarded to the proper subviews?
推荐答案
在手势识别器上将 delaysTouchesBegan
设置为 YES
,这样只会将触摸事件转发给子视图手势无法识别。
Set delaysTouchesBegan
to YES
on the gesture recognizer, which will make it only forward touch events to subviews if a gesture is not recognized.
这篇关于UIButton和Swipe Gesture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!