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 に答える