Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 允许UITableViewCell即使在滚动时也更新内容_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 允许UITableViewCell即使在滚动时也更新内容

Ios 允许UITableViewCell即使在滚动时也更新内容,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有一个UITableView包含一个自定义UITableView单元格,其中包含时间(最接近的毫秒)。滚动时,时间文本直到滚动停止后才会更新。我知道这可能是大多数人想要的默认行为,但我希望单元格即使在滚动时也能保持更新。有办法做到这一点吗?我在文档中找不到任何东西 单元格使用NSTimer每秒递归调用更新时间函数30次。此函数用于更新单元格上的UILabel。请签出以进行深入阅读。。长话短说,您需要将计时器设置为在公共模式下运行。这样,当其他东西占用UI线程时,它将更新。这就是我如何使用我的:

我有一个
UITableView
包含一个自定义
UITableView单元格
,其中包含时间(最接近的毫秒)。滚动时,时间文本直到滚动停止后才会更新。我知道这可能是大多数人想要的默认行为,但我希望单元格即使在滚动时也能保持更新。有办法做到这一点吗?我在文档中找不到任何东西

单元格使用
NSTimer
每秒递归调用更新时间函数30次。此函数用于更新单元格上的UILabel。

请签出以进行深入阅读。。长话短说,您需要将计时器设置为在公共模式下运行。这样,当其他东西占用UI线程时,它将更新。这就是我如何使用我的:

downloadAnimationTimer = [NSTimer scheduledTimerWithTimeInterval:.05 target:self selector:@selector(animateDownloadButtons) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:downloadAnimationTimer forMode:NSRunLoopCommonModes];

使用UITableViewDelegate。滚动tableView时调用此方法

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

    for (UITableViewCell* cell in arrayVisibleCells)
    {
        //update code
    }
}

这既不起作用,也不能回答问题