gpt4 book ai didi

ios - 我们可以在不重新加载的情况下调整 UITableViewCell 的大小吗?

转载 作者:可可西里 更新时间:2023-10-31 23:58:24 28 4
gpt4 key购买 nike

我们可以在不重新加载的情况下通过单击其中的按钮来更改 UITableViewCell 的内容大小吗?当我执行 reloadData()reloadCell() 时,UITableView 闪烁,我想避免这种闪烁。

最佳答案

您应该使用 beginUpdates()endUpdates() 来更改 UITableViewCell 的内容大小,在本例中为 heightForRowAtindexPath 将调用 tableView 中的每个单元格并更新 TableviewCell 的 height。对于 iOS > 10,您应该更喜欢 performBatchUpdates(_:completion:) 而不是 beginUpdates() 和 endUpdates()。

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.tableView.beginUpdates()
self.tableView.endUpdates()
}

更多信息

https://appengineer.in/2018/07/11/resize-uitableviewcell-size-without-fluctuation-and-jerk/

https://developer.apple.com/documentation/uikit/uitableview/1614908-beginupdates

关于ios - 我们可以在不重新加载的情况下调整 UITableViewCell 的大小吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51265234/

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