0

我有UIScrollView。我使用以下代码设置 contentOffset :

    [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) {
     }];

进入

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

方法和相同的代码进入

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView

当我进行垂直滚动时 - 滚动指示器的行为不正确,它会跳跃或保持在先前的位置。

我的错误在哪里?

4

1 回答 1

0

setContentOffset呼叫可以为您处理动画。通过animated:YES并失去UIView animationWithDuration:块。

换句话说,试试这个:

[comicsScrollView setContentOffset:CGPointMake(comicsScrollView.contentOffset.x,     
   currentView.frame.origin.y + currentView.bounds.size.height/2 -    
   comicsScrollView.bounds.size.height/2) animated:YES];
} completion:nil];
于 2013-01-14T14:22:40.607 回答