title: xcode, UIScrollView keep looping scroll animation
body: <p>Objective</p>
  
  <ul>
  <li>trying to make a scrollview, it able to auto scroll to left. after complete will auto scroll to right. and repeat.</li>
  </ul>
  
  <p>The scroll animation keep looping and keep go on the "AfterDone" method even the animation not yet complete.</p>
  
  <pre><code>- (void) afterAnimationStops{
  float newOffSetX = _tableview.bounds.size.width-wContentBgImg;
  NSLog(@"Inside AutoMove &gt; %d",LzAutoMove);
  if(leftright==1 &amp;&amp; LzAutoMove==0)
  {
      NSLog(@"Come In &gt; 1");
      LzAutoMove = 1;
      leftright = 2;
      [UIScrollView animateWithDuration:3.0f
                            delay:0.0f
                          options:UIViewAnimationOptionCurveEaseOut
                       animations:^{
                           [UIScrollView beginAnimations:@"scrollAnimation" context:nil];
                           [UIScrollView setAnimationDuration:3.0f];
                           LzcurrentLocation = (-newOffSetX);
                           [imgCell.scrollview setContentOffset:CGPointMake((-newOffSetX), 0)];
                           [UIScrollView commitAnimations];
                       }
                       completion:^(BOOL finished){
                           if (finished) {
                               [self afterDone];
                           }
                       }];
  }else{
      if(LzAutoMove==0){
      NSLog(@"Come In &gt; 2");
          LzAutoMove = 1;
          leftright = 1;
          [UIScrollView animateWithDuration:3.0f
                                      delay:0.0f
                                    options:UIViewAnimationOptionCurveEaseOut
                                 animations:^{
                                     [UIScrollView beginAnimations:@"scrollAnimation" context:nil];
                                     [UIScrollView setAnimationDuration:3.0f];
                                     LzcurrentLocation = 0;
                                     [imgCell.scrollview setContentOffset:CGPointMake(0, 0)];
                                     [UIScrollView commitAnimations];
                                     //[UIScrollView setAnimationDidStopSelector:@selector(afterDone)];
                                 }
                                 completion:^(BOOL finished){
                                     if (finished) {
                                         [self afterDone];
                                     }
                                 }];
  
      }
  
  }
  }
  
  - (void) afterDone{
      NSLog(@"Done");
      LzAutoMove = 0;
      [self afterAnimationStops];
  }
  </code></pre>
  
  <p>i still learning how to use the "animation completed" method, is that any one can show me where i doing wrong? thanks!</p>