THIS METHOD IS DEPRECATED SINCE iOS 7.0.
There is a UITableView
delegate method called heightForRowAtIndexPath
that is called before you create a cell or a table.
You could use the NSIndexPath
passed to it to get the text at a specific row and use the sizeWithFont
method from UIStringDrawing.h
to compute a CGSize
for that row.
For example:
CGSize size = [text sizeWithFont:font
constrainedToSize:maximumLabelSize
lineBreakMode:UILineBreakModeWordWrap];
And finally you would return size.height
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…