1

我想在没有动画的情况下设置滚动视图的内容偏移量。这是我应用的简单代码,但它不起作用:

[_scrollView setContentOffset:CGPointMake(self.frame.size.width*currentPage, 0) animated:NO];

在我返回滚动视图时执行我的任务后,它的索引重置为 0,然后重置为我当前的索引。那也行。但是为什么当我将动画设置为 NO 时会发生滚动动画。

请帮忙。

4

3 回答 3

0

尝试在下面停止动画:

    [CATransaction begin];
    [CATransaction setAnimationDuration:0];
    [CATransaction setDisableActions:YES];
    [_scrollView setContentOffset:CGPointZero animated:NO];
    [CATransaction commit];
于 2017-09-05T08:50:00.883 回答
0

利用:

_scrollView.contentOffset = CGPointMake(self.frame.size.width*currentPage, 0);
于 2016-09-27T08:34:21.670 回答
0

这成功了:

[ UIView performWithoutAnimation:^{ [_scrollView setContentOffset:CGPointMake(self.frame.size.width*currentPage, 0) animated:NO]; }];

于 2016-10-06T10:45:58.263 回答