title: UIScrollView not scrolling to proper location with setContentOffset:animated:
body: <p>I have a series of images in a UIScrollView. When the user releases the scrolling action, I want the view to center on a single image. I have the code implemented, but the underlying behavior is incorrect. My call to setContentOffset:animated: has the correct values, but the view doesn't actually scroll to that point.  Here is the output of some debugging:</p>
  
  <pre><code>2011-03-26 17:28:16.201 PivotMachine[39984:207] Dragging Beginning at: 270,   0
  2011-03-26 17:28:16.322 PivotMachine[39984:207]     Dragging Ended at: 360,   0 --&gt; 350,   0
  2011-03-26 17:28:16.624 PivotMachine[39984:207]    Scrolling Ended at: 350,   0
  2011-03-26 17:28:25.648 PivotMachine[39984:207] Dragging Beginning at: 447,   0
  </code></pre>
  
  <p>As you can see, internally, it thought it stopped dragging at 360, so properly advanced to 350, where it should have been. Visually, it is sitting around 450 instead, which it knows about when I start dragging again (yes, I know you don't get the beginning immediately, so I'm dragging very slowly to only move a couple pixels before the event).</p>
  
  <p>This is the dragging code (for my UIScrollView subclass):</p>
  
  <pre><code>- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  {
      CGPoint myLocation = self.contentOffset;
      NSLog(@"Dragging Beginning at: %3.0f, %3.0f", myLocation.x, myLocation.y);
  }
  
  - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollV
  {
      CGPoint myLocation = self.contentOffset;
      NSLog(@"   Scrolling Ended at: %3.0f, %3.0f", myLocation.x, myLocation.y);
  }
  
  - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
  {
      // Auto-scroll to the center of the closest menu
      if (scrollView != self)
      {
          DLog(@"[ScrollMenu scrollViewWillBeginDecelerating] called with non-self");
          return;
      }
      CGPoint myLocation = self.contentOffset;
      int idx = [self indexOfMenuClosestTo:myLocation];
      CGPoint menuPoint = CGPointMake(menuPoints[idx], self.contentOffset.y);
      NSLog(@"    Dragging Ended at: %3.0f, %3.0f --&gt; %3.0f, %3.0f",
           myLocation.x, myLocation.y, menuPoint.x, menuPoint.y);
      [self setContentOffset:menuPoint animated:YES];
  }
  </code></pre>
  
  <p>I should note that this is in the simulator. I can't try it on the actual phone yet, since I haven't spent the money on the dev program yet (waiting until I have the app nearly ready to publish in case I run out of steam :).</p>
  
  <p>Could this be a simulator problem? Has anybody seen something similar? Oh, yeah, I should ask: am I doing something wrong? ;)</p>
  
  <p><strong>Follow Up:</strong> I think the problem is that the deceleration animation is conflicting with my <code>-(void) setContentOffset:animated:</code> call. Both animations continue running and the view displays whichever wins, but the internal state is based correctly on <code>setContentOffset</code>. I thought <code>setContentOffset</code> turned off the existing animation. Does it, and, if not, how can I turn it off?</p>