0

我想知道如何比这更快地检测到“滑动”?一旦用户将手指向左移动,我想调用一个方法。让我们称之为“小”滑动手势。

这将是正常/长滑动......</p>

UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
recognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[scrollView addGestureRecognizer:recognizer];
[recognizer release];
[scrollView delaysContentTouches];
4

1 回答 1

1

现在我建立这个:

#import "UICustomScrollView.h"

@implementation UICustomScrollView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // do stuff
    }
    return self;
}

// Listen for "fast" swipe
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {


    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView:self];
    CGPoint prevLocation = [touch previousLocationInView:self];

    if (location.y - prevLocation.y > 0) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"fastSwipe" object:self];
    }    

    [super touchesMoved:touches withEvent:event];
}


@end
于 2012-06-19T19:54:50.510 回答