UITableViewCells
Can tableview cells be dynamically configured so different cells can have different heights, based on data/text content? Does this violate Human Interface Guidelines? The documentation I have found is spotty and confusing, at l开发者_如何学JAVAeast to newbies like me! :)
You can specify the height for each cell by implementing the tableView:heightForRowAtIndexPath:
method in your UITableViewDelegate; note this will be called for every row, even rows not currently visible, so it must be fast and you may have trouble if your table has thousands of rows.
The only statement I see regarding cells with different heights in the HIG is "Avoid variable row heights in a plain table. Variable row heights are acceptable in grouped tables, but they can make a plain table look cluttered and uneven."
The UITableViewCell does not control its own height.
To set the height of a row in the table, implement the UITableViewDelegate method tableView:heightForRowAtIndexPath:
This can be somewhat painful sometimes - since often the cell is the best place to calculate its own height. The pattern I use is to implement a class method on the custom UITableViewCell class to calculate the cell's height given the data it is displaying. Call this from your implementation of tableView:heightForRowAtIndexPath:
I've never had an app rejected for variable height rows in either plain or grouped tables.
精彩评论