我想知道如何比这更快地检测到“滑动”?当用户将手指向左移动时,我想将方法称为soons。 我们称之为“小”滑动手势。
这将是正常/长时间滑动......
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
recognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[scrollView addGestureRecognizer:recognizer];
[recognizer release];
[scrollView delaysContentTouches];
答案 0 :(得分: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