我有点沮丧。我有一个iOS 10项目UITableView
和UITableViewAutomaticDimension
单元。我正确设置了约束。UITableView cellForRowAt vs willDisplay
起初我映射我的细胞内部
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)
后这我的自动布局单元停止正常工作。
我的理解,在高度cellForRowAt
之后,但之前willDisplay
计算,所以当我在willDisplay
高度映射已被设置为我的手机,我需要重新加载它(这是不好的)。
任何人都可以证明/解释这一点?
UPDATE:
发布提问后,我发现这篇文章:https://tech.zalando.com/blog/proper-use-of-cellforrowatindexpath-and-willdisplaycell/
您可以将我的回答标记为答案? –