我有一个静态单元格的表格。对于一个细胞,我想根据标签的高度(在细胞内)改变其高度,同时保持所有其他细胞高度不变。我如何获得当前细胞的高度?或者,也许有更好的方法?heightForRowAtIndexPath中的当前单元格高度?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath section] == 2) {
return self.myLabel.frame.origin.y *2 + self.myLabel.frame.size.height;
} else {
return ...; // what should go here, so the cell doesn't change its height?
}
}
您单元的默认高度去那里。 44如果你没有改变任何东西。 – Desdenova 2013-04-10 13:50:58
您还可以使用UIKIt对NSString方法'sizeWithFont:'的扩展来计算标签的单元实际所需高度。 – 2013-04-10 13:56:23