How to get the cell object in tableView:(UITableView *)tableView heightForRowAtIndexPath function?

后端 未结 5 1664
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 19:19

I wand to know the content of the cell when returning the heightForRowAtIndexPath. In this function how do I get the cell object?

- (CGFloat) tableView:(UITa         


        
5条回答
  •  天命终不由人
    2020-12-18 19:59

    The cell hasn't been created when heightForRowAtIndexPath: is called, so there's no way to "get" a cell. Instead, look at your model and determine the height of the cell that way.

    If you're concerned about long strings and needing more vertical space in your cell, consider using sizeWithFont:forWidth:lineBreakMode:. Docs here: https://developer.apple.com/library/ios/#documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html

提交回复
热议问题