无法在自定义的uitableviewcell中更改uilabel的高度

时间:2013-11-16 08:53:55

标签: ios uitableview size

我正试图在 -

中的自定义uitableviewcell中更改uilabel的高度
    (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath.

问题是,除非我向下和向后滚动桌面视图,否则uilabel的高度不会改变。

任何人都知道如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

你可以尝试

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
return labelHeight;
}

行值的高度大于标签高度。

答案 1 :(得分:0)

对于多行标签,您需要设置

cell.textLabel.numberOfLines = 0;

然后

[cell.textLabel sizeToFit];