Read highly open source code of cache cell: UITableView-FDTemplateLayoutCell,
How do you calculate the height of a cell? Well, I believe you can calculate it, or you may use the autolayout feature to get the size after fit. However, you have met the long and long tableview, do you think tableview is not silky smooth?
When optimizing the performance of tableview, If You Can cache the cell height, you are a little closer to success.
Now, let me introduce this framework a little. Address: https://github.com/forkingdog/uitableview-fdtemplatelayoutcellclick to open the link
This framework caches Data Based on indexPath as the key value.
Then, when the cell height is calculated for the first time
CGSize fittingSize = [cell. contentView systemLayoutSizeFittingSize: UILayoutFittingCompressedSize];
Use autolayout to obtain the size.
However, you may imagine something imperfect.
When your tableview occasionally deletes cells, isn't the height messy?
Yes, so you can cache the cell height in your data service code. Therefore, this framework is worth learning.