4

I have a UITableView containing a custom UITableViewCell that contains the time (up to the nearest millisecond). When scrolling, the time text doesn't update until after the scrolling stops. I know this is probably the desired default behaviour for most people, but I want the cell to keep updating even when scrolling. Is there a way to do this? I couldn't find anything in the documentation.

The cell uses an NSTimer to recursively call the update time function 30 times a second. This function updates a UILabel on the cell.

Alex Blundell
  • 2,084
  • 5
  • 22
  • 31

2 Answers2

4

Check out this answer for some in depth reading.. Long story short you need to set your timer to run in common mode. That way it will update while other things are taking the UI thread. This is how I use mine:

downloadAnimationTimer = [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(animateDownloadButtons) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:downloadAnimationTimer forMode:NSRunLoopCommonModes];
Community
  • 1
  • 1
Putz1103
  • 6,211
  • 1
  • 18
  • 25
-2

Use UITableViewDelegate. This method is called when scroll tableView.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSArray* arrayVisibleCells = [tableViewContent visibleCells];

    for (UITableViewCell* cell in arrayVisibleCells)
    {
        //update code
    }
}
user2828120
  • 233
  • 4
  • 13