Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton and Swipe Gesture

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?

like image 828
Clay Avatar asked May 07 '13 16:05

Clay


2 Answers

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

like image 187
jszumski Avatar answered Sep 25 '22 08:09

jszumski


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

like image 41
csundman Avatar answered Sep 26 '22 08:09

csundman