开发者

UITableView height of a section

I have a UITableView that has 3 sections. My individual cells vary in height (collapse-expand). I need a way to figur开发者_Python百科e out the height of each individual section, i.e. the sum of cell heights in each section. Preferably without calculating everything the tableView already has done each time I need it.

I there a way to deduce or access such a value?


Did you look at -rectForSection: (and possibly also -rectForFooterInSection:)?


There is no easy way to calculate the value, however there is a way. If your cells have a fixed height it's just the many rows multiplied by their fixed height for each section.

If you have varying height in the cells too, I'd go for an array which holds the total height for each section, just calculate it once and keep it cached there. If the section is collapsed you just need the section header height else it's the value in the array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜