Gesture problem: UISwipeGestureRecognizer + UISlider

The simplest way to handle this is probably to prevent the gesture recognizer from seeing touches on your slider. You can do that by setting yourself as the delegate, and then implementing

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if ([touch.view isKindOfClass:[UISlider class]]) {
        // prevent recognizing touches on the slider
        return NO;
    }
    return YES;
}

If this doesn’t work, it’s possible the slider actually has subviews that receive the touch, so you could walk up the superview chain, testing each view along the way.

Leave a Comment