【问题标题】:Incorrect behavior of the scroll's indicator滚动指示器的不正确行为
【发布时间】:2012-12-28 10:45:42
【问题描述】:

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

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

我的错误在哪里?

【问题讨论】:

    标签: iphone uiscrollview scroll uiscrollviewdelegate


    【解决方案1】:

    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];
    

    【讨论】:

    • 这不是我的任务的方法,因为它延迟动画,我的意思是:滚动 [setContentOffset:CGPointMake(x,y) animated:YES] 延迟调用后,我需要一个滴答反应.
    猜你喜欢
    • 2018-05-26
    • 2012-06-13
    • 2011-01-02
    • 2013-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多