滚动指示符的行为不正确

时间:2013-01-14 13:12:17

标签: iphone uiscrollview scroll uiscrollviewdelegate

我有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

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

我的错误在哪里?

1 个答案:

答案 0 :(得分: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];