title: Finding the direction of scrolling in a UIScrollView?
body: <p>I have a <code>UIScrollView</code> with only horizontal scrolling allowed, and I would like to know which direction (left, right) the user scrolls. What I did was to subclass the <code>UIScrollView</code> and override the <code>touchesMoved</code> method:</p>
  
  <pre><code>- (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 &gt; before){
          right = NO;
          NSLog(@"LEFT");
      }
      else{
          right = YES;
          NSLog(@"RIGHT");
  
      }
  
  }
  </code></pre>
  
  <p>But this method sometimes doesn't get called at all when I move. What do you think?</p>