0

I have UIScrollView. I set contentOffset using the code :

    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut animations:^{
    [comicsScrollView setContentOffset:CGPointMake(comicsScrollView.contentOffset.x, currentView.frame.origin.y + currentView.bounds.size.height/2 - comicsScrollView.bounds.size.height/2) animated:NO];
        } completion:^(BOOL finished) {
     }];

Into

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

method and the same code into

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView

When I make vertical scroll - scroll's indicator has an incorrect behavior, It jumps or remains in previous position.

Where is my mistake?

Constantinius
  • 34,183
  • 8
  • 77
  • 85

1 Answers1

0

The setContentOffset call can handle animation for you. Pass in animated:YES and lose the UIView animationWithDuration: block.

In other words, just try this:

[comicsScrollView setContentOffset:CGPointMake(comicsScrollView.contentOffset.x,     
   currentView.frame.origin.y + currentView.bounds.size.height/2 -    
   comicsScrollView.bounds.size.height/2) animated:YES];
} completion:nil];
occulus
  • 16,959
  • 6
  • 53
  • 76
  • It's a method not for my task, because it delay animation, what I mean: after scrolling [setContentOffset:CGPointMake(x,y) animated:YES] calls with delay, I need in a tick reaction. – Alexander Ermolaev Jan 15 '13 at 08:37