最佳答案
我有一个只允许水平滚动的UIScrollView
,我想知道用户滚动的方向(左,右)。我所做的是子类化__abc0并覆盖__abc2方法:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
UITouch *touch = [touches anyObject];
float now = [touch locationInView:self].x;
float before = [touch previousLocationInView:self].x;
NSLog(@"%f %f", before, now);
if (now > before){
right = NO;
NSLog(@"LEFT");
}
else{
right = YES;
NSLog(@"RIGHT");
}
}
但是当我移动时,这个方法有时根本不会被调用。你怎么看?