UIButton and Swipe Gesture

2019-05-04 08:35发布

I have a UIView with two UIButtons 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 UIButtons are catching the input.

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?

2条回答
SAY GOODBYE
2楼-- · 2019-05-04 09:29

Set delaysTouchesBegan to YES on the gesture recognizer, which will make it only forward touch events to subviews if a gesture is not recognized.

查看更多
Summer. ? 凉城
3楼-- · 2019-05-04 09:29

How do you currently have the UIButtons set up to receive the input? Make sure that the selector you are hooking up the UIButton is hooked up with "Touch Up Inside". This should ensure that a swipe that begins on one of the buttons does not actually activate the button (assuming the user swipes all the way off the button).

查看更多
登录 后发表回答