我在 scrollView 上有大约 9 个图像,我想让它逐个图像自动滚动(比如第一个图像滚动到第二个,直到最后一个)。我做了这样的事情:
timer = [NSTimer scheduledTimerWithTimeInterval:.0 target:self selector:@selector(scrolling) userInfo:nil repeats:NO];
- (void)scrolling{
CGFloat currentOffset = scrollView.contentOffset.x;
if(currentOffset < 2236){
CGFloat newOffset = currentOffset + 172;
[UIScrollView beginAnimations:nil context:NULL];
[UIScrollView setAnimationDuration:2.1];
[scrollView setContentOffset:CGPointMake(newOffset,0.0) animated:YES];
[UIScrollView commitAnimations];
}
但它只滚动一次(从第一张图像到第二张图像)。我做错了什么?任何想法?