UIScrollView滚动事件块UIViewanimation

我有一个UIImageView的animation设置,代表一个当前的值,并不断地继续滴答下去…理想情况下永远不会停止,在视图中也是一个scrollView或者当我滚动或放大scrollView时,animation停止,当scrollView完全停止移动时再次启动。 我相信这是由于线程的问题,因为重绘元素都发生在主线程,首先我试图UIViewanimation,然后甚至核心animation没有影响…有没有办法让我的蛋糕,吃呢?

任何和所有的帮助,将不胜感激

代码如下

- (void)TestJackpotAtRate:(double)rateOfchange { double roc = rateOfchange; for (int i = 0; i < [_jackPotDigits count]; ++i) { roc = rateOfchange/(pow(10, i)); UIImageView *jackpotDigit = [_jackPotDigits objectAtIndex:i]; float foreveryNseconds = 1/roc; NSDictionary *dict = @{@"interval" : [NSNumber numberWithFloat:foreveryNseconds], @"jackPotDigit" : jackpotDigit }; [NSTimer scheduledTimerWithTimeInterval:foreveryNseconds target:self selector:@selector(AscendDigit:) userInfo:dict repeats:YES]; } } -(void)AscendDigit:(NSTimer*)timer { NSDictionary *dict = [timer userInfo]; NSTimeInterval interval = [(NSNumber*)[dict objectForKey:@"interval"] floatValue]; UIImageView *jackpotDigit = [dict objectForKey:@"jackPotDigit"]; float duration = (interval < 1) ? interval : 1; if (jackpotDigit.frame.origin.y < -230 ) { NSLog(@"hit"); [timer invalidate]; CGRect frame = jackpotDigit.frame; frame.origin.y = 0; [jackpotDigit setFrame:frame]; [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(AscendDigit:) userInfo:dict repeats:YES]; } [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^ { CGRect frame = [jackpotDigit frame]; double yDisplacement = 25; frame.origin.y -= yDisplacement; [jackpotDigit setFrame:frame]; } completion:^(BOOL finished) { }]; } 

作为danypata在我的意见通过这个线程指出我的自定义用户界面元素不被更新,而UIScrollView滚动它与NStimer线程,而不是animation线程,或者如果有人可以澄清,可能两者。 在任何情况下,当滚动似乎所有的滚动事件独占使用的主循环,解决的办法是把你正在使用的计时器做你的animation到相同的循环模式,这是UITrackingLoopMode所以它也得到使用主循环滚动和…

 NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:foreveryNseconds target:self selector:@selector(AscendDigit:) userInfo:dict repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 

田田。