在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];
}
代码运行之后,只有第一张图片滚动了。哪出错了?