1

我有一个包含大约 11 个图像的滚动视图,并且滚动视图将在屏幕上仅显示一个图像。我需要让它自动滚动图像。我做了这样的事情:

[UIView animateWithDuration:120
                      delay:1
                    options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction
                 animations:^{        
                     self.scrollView.contentOffset = CGPointMake(self.scrollView.contentOffset.x+172*11,0);

                 }
                 completion:nil]; 

滚动视图滚动其所有宽度,我可以看到图像之间的连接。是否可以通过设置 contentOffset 来自动滚动?

谢谢

4

1 回答 1

5

I made my UIScrollView Auto Scroll by set contentOffset like this:

[NSTimer scheduledTimerWithTimeInterval:.0 target:self selector:@selector(loadUrl) userInfo:nil repeats:NO];

- (void) loadUrl
{
    currentOffset = scrlFirstScroll.contentOffset.y;
    CGFloat newOffset = currentOffset + 3;
    [scrlFirstScroll setContentOffset:CGPointMake(0.0,newOffset) animated:YES];
}

Hope this will help..

于 2013-06-20T11:44:50.013 回答