我需要以编程方式仅设置一行的高度,所有其他行都是在情节提要中创建的具有不同高度的静态单元格。
在我的代码中,第 5 个单元格应默认为“隐藏”,因此我想将此行的高度设置为 0.0。所有其他单元格都应该使用它们在情节提要中的高度,我正在使用该方法tableView:heightForRowAtIndexPath
来设置单元格的高度。
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat height = self.tableView.rowHeight;
if (indexPath.row == 4)
{
height = 0.0f;
}
return height;
}
问题是self.tableView.rowHeight
总是返回658
高度,这是一个完全错误的值。