UIScrollView scroll event blocks UIView animation

后端 未结 2 1682
灰色年华
灰色年华 2021-02-04 14:41

I have an animating set of UIImageView\'s that represent a current value and continually keeps ticking upwards...ideally never stopping, also in the view is a scrollView or to a

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 14:56

    As danypata pointed out in my comments via this thread My custom UI elements are not being updated while UIScrollView is scrolled It has something to do with the NStimer thread rather than the animation thread, or possibly both if someone can clarify. In any case when scrolling it seems all scroll events get exclusive use of the main loop, the solution is to put the timer you are using to do your animation into the same loop mode which is UITrackingLoopMode so it too get's use of the main loop when scrolling and...

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

    Tada.

提交回复
热议问题