我有点沮丧。我有一个UITableView
带有UITableViewAutomaticDimension
单元格的 iOS 10 项目。我正确设置了约束。
最初我在里面映射我的细胞
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
一切正常,但后来我读了一篇文章:https ://medium.com/ios-os-x-development/perfect-smooth-scrolling-in-uitableviews-fd609d5275a5#.4rnbc4vyg并将我的数据映射移动到
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
在此之后,我的自动布局单元停止正常工作。
我的理解是 at height 是在 after cellForRowAt
but before计算的willDisplay
,所以当我映射willDisplay
高度时,我的单元格已经设置好了,我需要重新加载它(这不好)。
任何人都可以证明/解释这一点吗?
更新:
发布一个问题后,我找到了这篇文章:https ://tech.zalando.com/blog/proper-use-of-cellforrowatindexpath-and-willdisplaycell/