Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to implement UIGestureRecognizerDelegate for a UIScrollView?

$
0
0

A UIScrollView has it's own gesture recognizers, e.g. for panning. I'd like to override some functionality with regards to the panning of a UIScrollView. More specifically, I want a scrollview to stop recognizing multiple gestures if the y velocity of a pan gesture is lower as 0.25f.

In Objective-C the code would look like the following (MyScrollView is a subclass of UIScrollView and implements the UIGestureRecognizerDelegate protocol):

@implementation MyCellScrollView

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {        
        CGFloat yVelocity = [(UIPanGestureRecognizer*)gestureRecognizer velocityInView:gestureRecognizer.view].y;        
        return fabs(yVelocity) <= 0.25;        
    }
    return YES;
}

@end

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>