Uitable automatic cell height adaptation and uitable cell adaptation

Source: Internet
Author: User

Uitable automatic cell height adaptation and uitable cell adaptation

Uitable cell height automatic adaptation of the premise is that you want to enable the auto layout option, do not understand or not familiar with the first look here http://lvwenhan.com/ios/430.html


Follow the steps in many use cases, but do not want to step on it:

1. Disable proxy function-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath;

2. Then implement-(CGFloat) tableView :( UITableView *) tableView estimatedHeightForRowAtIndexPath :( NSIndexPath *) indexPath
Note that the two proxy functions look very similar, but the names are indeed different. EstimatedHeightForRowAtIndexPath is a new API provided from iOS7. It is more efficient than heightForRowAtIndexPath, because it only obtains the height of the cells to be displayed. After an internship on a case-based basis, the cell height remains unchanged and will not be adaptive.


Finally, I tried another method and finally succeeded. The method is as follows:

1. Neither heightForRowAtIndexPath nor estimatedHeightForRowAtIndexPath;

2. Set the following attributes for uitable:

TableView. estimatedRowHeight = 10.0;
TableView. rowHeight = UITableViewAutomaticDimension;


Run the command and you will see the effect. Why is the first method not working? I think there may be a lack of steps. I have copied a large copy of the article on the internet, and I guess I have not tested it, so I will reprinted it. Have time to see where the problem with the first method is.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.