我有一个带有标签的自定义单元格。我想要做的是制作标签sizeToFit
并将cellForRow...
标签高度传递给一个名为labelHeight
. 然后在heightForRow...
我想返回labelHeight
。
问题是,它返回的高度为 0。这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
[customCell.label sizeToFit];
self.labelHeight = customCell.label.frame.size.height;
...
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
return self.labelHeight;
}