IOS Tableviewcell The problem encountered in the custom height method, cell height is 0,cell display, cell directly shows the first few instead of ... cell display number is incorrect

Source: Internet
Author: User

Encounter the above problems can be seen in your cell height is there, the height of the custom, there is continued to see, no further Baidu ...

In the text layout, there is no adaptive text height, line spacing or something, obviously the height of the cell is not fixed, if the use of custom cells, but also in time to send the height of the cell, to assign values;

In-(uitableviewcell*) TableView ... cellforrow ... { You can calculate the cell height in the inside, you need to assign the value to the Cell.height= property ;

It is not possible to set the global CGFloat value, because the assignment is not finished, and the Heightrow method has already assigned the null value of float;}

In the Heightforrow method, the cell is retrieved for assignment:

if (indexpath.row<9) {//This inside is full of custom height/before with cell.height= assignment;

UITableViewCell * Cell =[self tableview:tableview Cellforrowatindexpath:indexpath];

return cell.height;

}

That's it.

IOS Tableviewcell The problem encountered in the custom height method, cell height is 0,cell display, cell directly shows the first few instead of ... cell display number is incorrect

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.