1

动态设置自定义 UITableViewCell 高度。如果文本包含换行符,则计算出的高度不正确。

在此处输入图像描述

在此处输入图像描述

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{         
        CGSize constraintSize = {320.0, 20000};
        CGSize neededSize = [_beerDetails.notes sizeWithFont:[UIFont systemFontOfSize:10.0f] constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
        return neededSize.height + 50;
}
4

1 回答 1

0

'constraintSize' 中的宽度是否应不小于 320(因为这是 iPhone 屏幕的全宽)?您可以尝试 300 或 290 的宽度。

于 2013-03-16T03:55:47.437 回答