gpt4 book ai didi

ios - UITableView 很滞后,滚动时会跳动

转载 作者:行者123 更新时间:2023-11-28 08:56:46 25 4
gpt4 key购买 nike

我正在使用带有动态单元格的 UITableView。每个单元格都有一些按钮、图像和标签。图片的宽度等于tableview的宽度,高度是可变的。

我正在通过一个函数更新 cellForRowAtIndexPath 中图像的高度...以遵守纵横比。标签可以有 1 行或多行。

我正在使用 heightForRowAtIndexPath 来设置单元格的高度。我在那里计算并返回值。

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {

let queficient = CGFloat(dataController.Data[indexPath.row].width) / self.view.frame.size.width

let imgHeight = CGFloat(dataController.Data[indexPath.row].height) / queficient

return 134 + imgHeight + heightForView(dataController.Data[indexPath.row].description)
}

我不知道为什么滚动时表格有点滞后和跳跃。

最佳答案

如果您确定延迟是由 heightforRowAtIndexPath 引起的,为什么不在图像更改时只计算一次每个单元格数据/索引路径的高度?

你应该只返回 dataController.Data[indexPath.row].calculatedCellHeight 或其他东西

关于ios - UITableView 很滞后,滚动时会跳动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32847296/

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