I'm a little frustrated. I have a iOS 10 project UITableView
with UITableViewAutomaticDimension
cells. I set constraints properly.
Initially I was mapping my cells inside
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
and everything was working fine, but then I read an article: https://medium.com/ios-os-x-development/perfect-smooth-scrolling-in-uitableviews-fd609d5275a5#.4rnbc4vyg and moved my data mapping to
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)
after this my auto layout cells stopped to work properly.
My understanding that at height is calculating after cellForRowAt
but before willDisplay
, so when I'm mapping in willDisplay
height is already set for my cell and I need to reload it again (which is not good).
Anyone can proof/explain this?
UPDATE:
After posting a question, I found this article: https://tech.zalando.com/blog/proper-use-of-cellforrowatindexpath-and-willdisplaycell/