Read highly open source code of cache cell: UITableView-FDTemplateLayoutCell,

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.