I have a UISwipeGestureRecognizer
that animates accordingly to which UIButton
is highlighted at the time of the gesture, it finishes the animation when the UIButton
calls TouchUpInside/TouchUpOutside. This works fine for a downward swipe gesture on my UIButton
but for some reason when I try a upward swipe (on another UISwipeGestureRecognizer
), it doesn't run the function. (yes it is the same UIButton
) This is what I did in viewDidLoad:
[myButton addTarget:self action:@selector(myAction) forControlEvents:(UIControlEventTouchUpInside|UIControlEventTouchUpOutside)];
For the action I just used:
-(void) myAction{
//Do whatever I want to do, in this case finish the animation.
}
None of the code that I run for the swipe gesture should even effect the UIButton
, so I guess I'm wondering if anyone has any idea what I could be doing wrong here?
Edit: It seems like the problem is that when I drag upwards too fast the button loses the "focus" (the highlight), therefore TouchUpInside/TouchUpOutside aren't getting called, but when I drag downwards at any speed the UIButton
stays highlighted the entire time, anyway to fix this? (see GIF)
I've fixed it! (Finally, pretty stupid of me) The reason TouchUpInside/TouchUpOutside didn't get called was because I forgot to add
myGesture.cancelsTouchesInView=NO;
For all my gesture recognizers, thanks anyway everyone.