UIScrollView Jerky Scrolling

时间:2013-06-15 07:40:29

标签: ios ios5 ios6 uiscrollview uiviewanimation

我有一个很棒的滚动视图。我只想在按下每个按钮时按固定步骤滚动滚动视图。但是,当我编写以下代码时,滚动视图滚动是非常锯齿状的。有人可以解释原因吗?

CGPoint lstructCurrentPoint = self.objScrollView.contentOffset;
lstructCurrentPoint.x += 400;

        [UIView animateWithDuration:1.0f
                              delay:0.0f
                            options:UIViewAnimationOptionCurveLinear
                         animations:^{
                             [self.objScrollView scrollRectToVisible:CGRectMake(lstructCurrentPoint.x,
                                                                                lstructCurrentPoint.y,
                                                                                self.objScrollView.bounds.size.width,
                                                                                self.objScrollView.bounds.size.height)
                                                            animated:NO];
                        } completion:^(BOOL finished)
                         {
                         }];

我不使用动画:是的争论,因为我需要在不同的contentOffsets之间自定义滚动速度。

5 个答案:

答案 0 :(得分:1)

当您更新scroolview内容框架而滚动动画时,就像您尝试更新过去已经更改的内容...(可能不是最好的解释:D)

在动画选项中尝试使用它:

options:UIViewAnimationOptionCurveLinear|UIViewAnimationOptionBeginFromCurrentState

答案 1 :(得分:0)

为什么不尝试使用

[self.objScrollView scrollRectToVisible:CGRectMake(lstructCurrentPoint.x, lstructCurrentPoint.y,self.objScrollView.bounds.size.width,self.objScrollView.bounds.size.height) animated:YES];

而不是在UIView动画函数中使用它。

答案 2 :(得分:0)

尝试使用

[self.objScrollView setContentOffset: CGPointMame(lstructCurrentPoint.x, lstructCurrentPoint.y) animated: YES];

而不是scrollRectToVisible。

答案 3 :(得分:0)

scrollRectToVisible动画本身就是一个动画。

使用当前代码,您正试图为动画设置动画。

因此它是生涩的。

只需使用将矩形滚动到可见:

[self.objScrollView scrollRectToVisible:CGRectMake(lstructCurrentPoint.x,lstructCurrentPoint.y,self.objScrollView.bounds.size.width,self.objScrollView.bounds.size.height) animated:YES];

答案 4 :(得分:0)

如果不知道你在scrollView中有什么内容,没有人可以正确回答你的问题。

但是,你可以自己找出导致这种情况的原因。

在您的设备上配置应用。这将打开仪器。选择核心动画工具。

当应用程序运行时,滚动视图以便仪器捕获数据。

现在,Time Profiler部分将告诉您确切需要很长时间的内容。解决这个问题,你就可以顺利滚动。