UITableViewCell animations stop when UITableView is scrolling

后端 未结 2 1388
灰色年华
灰色年华 2021-02-10 09:20

I am making an \'event countdown\' scene in my app that uses a UITableViewController to show a list of events that are happening in the future. In each cell I have a countdown t

2条回答
  •  误落风尘
    2021-02-10 09:33

    Some more searching on this same issue for UIScrollViews yielded led me to this postMy custom UI elements...

    Basically what is happening is that the NSTimer I was using was not being updated when scrolling because scrolling blocks everything outside of its own run loop mode. The fix is to add the animation NSTimer to the same run loop mode that is used by scrolling: NSRunLoopCommonModes

    Here's how to do it in code:

    NSTimer *timer = [NSTimer timerWithTimeInterval:0.25 self selector:@selector(updateCountdownLabels) userInfo:nil repeats:YES]; 
    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
    

提交回复
热议问题