Cell adaptability of iOS UITableview, uitableviewcell

Source: Internet
Author: User

Cell adaptability of iOS UITableview, uitableviewcell

Background: In the past few days, we have encountered the cell adaptive height problem.

First, we must know the proxy execution sequence of UITableViewcell. In iOS7, a proxy method named tableView: estimatedHeightForRowAtIndexPath: appears. First, we must know that the height of the cell must be calculated when UITableViewcell is used, what if the cell content is dynamic? At this time, we must dynamically return the height, which is back to the problems encountered in our project. With this in mind, we need to know the execution sequence of the UITableViewde proxy method, such:

 

We can see that heightForRowAtIndexPath is executed before cellForRowAtIndexPath is executed. That is to say, heightForRowAtIndexPath is called when the cell does not exist, which cannot meet the project requirements, until the new API appears in iOS7, this is what we mentioned above: tableView: estimatedHeightForRowAtIndexPath:. This proxy method returns an estimated height to the cell. If this method is implemented, this means that the execution sequence of the proxy method of UITableView is changed, for example:

 

A little bit of sorting will draw the following conclusions:

Simply put, the height is estimated to give tableView a bottom picture and draw the cell first, but the actual cell height will still be obtained from the heightForRow... method.


References:

 

Text/CoderAO (simplified author)
Link: http://www.jianshu.com/p/6ab92579fcf1
Copyright belongs to the author. For reprinted content, contact the author for authorization and mark "author of simplified book ".

Related Article

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.