gpt4 book ai didi

ios - UITableView 滚动

转载 作者:行者123 更新时间:2023-11-28 22:53:33 25 4
gpt4 key购买 nike

我用 10 行填充了一个 TableView 。当我向上滚动表格时,前 2 或 3 行会卡住一段时间。我只看到最后一行 2 或 3 秒。我意识到滚动表格会调用 cellForRowAtIndexPath 和 willDisplayCell 函数。我使用那些功能。似乎对这些功能的调用减少了响应时间。滚动表格时如何禁用调用这些函数?请注意,我不想禁用滚动。

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

cell.textLabel.text = [[self.items objectAtIndex:indexPath.row] valueForKey:@"name"];

if ([indexPath row] % 2)
cell.backgroundColor = [UIColor whiteColor];
else
cell.backgroundColor = [UIColor colorWithRed:0/255.0 green:46/255.0 blue:59/255.0 alpha:0.1];

return cell;

最佳答案

你不能这样做,这是 tableview 的正常行为,但是你应该提高这些函数的性能,例如,如果你确实从远程源加载图像,请考虑使用延迟加载技术

关于ios - UITableView 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11299428/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com