Ios 使用nstimer在无限滚动视图中滑动图像

Ios 使用nstimer在无限滚动视图中滑动图像,ios,objective-c,uiscrollview,nstimer,Ios,Objective C,Uiscrollview,Nstimer,我有三张图片。这些图片应该像一个轮子一样从右到左每4秒设置一次动画。如果用户拖动到第二张图像,则在4秒钟后从第二张到第三张开始滑动。如何实现这一点 目前,我正在使用下面的代码,但它不是预期的工作 [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(doAnimation) userInfo:nil repeats:YES]; -(void)doAnimation { if (cur

我有三张图片。这些图片应该像一个轮子一样从右到左每4秒设置一次动画。如果用户拖动到第二张图像,则在4秒钟后从第二张到第三张开始滑动。如何实现这一点

目前,我正在使用下面的代码,但它不是预期的工作

   [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(doAnimation) userInfo:nil repeats:YES];

-(void)doAnimation
{

    if (currentPage) {

        [self scrollFromCurrentpage];
        return;
    }

    //CGPoint p=CGPointMake(count*320, 0);

    if (count==3) {
        count=0;

        [_scrollView setContentOffset:CGPointMake(0, 0)animated:NO];

        return;
    }


    count++;
    [UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^
     {
         CGRect rect= CGRectMake(count*320, 0, 320, 352);
         [_scrollView scrollRectToVisible:rect animated:NO];

     }completion:^(BOOL finished)
     {


     }];
}
-(void)scrollFromCurrentpage
{

    [UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^
     {
         CGRect rect= CGRectMake(currentPage*320, 0, 320, 352);
         [_scrollView scrollRectToVisible:rect animated:NO];
         currentPage=0;

     }completion:^(BOOL finished)
     {


     }];
}

NSTimer
实例设置属性。您应该实现一种方法,每次用户手动滚动时,
invalidate
并重置
NSTimer
实例。

请给出正确的实现