【问题标题】:How to set the default UITableViewCell height?如何设置默认的 UITableViewCell 高度?
【发布时间】:2011-06-25 19:46:14
【问题描述】:

我正在为我的 UITableViewCells 使用可变高度。但是,这通常可以正常工作 我发现无论最后一个单元格的高度是多少,它都会成为它下面所有空白单元格的高度。

有没有办法为出现在最后一个单元格下方的空白单元格设置默认高度?

谢谢。

【问题讨论】:

  • this question,它可能会有所帮助。不要错过对已接受答案的评论。

标签: uitableview


【解决方案1】:

如果你使用 switch 语句,那么在 switch 的默认情况下设置空单元格的默认高度。像这样

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    int rowHeight = 40;
    switch (indexPath.row) {
        case 0:
            rowHeight = 80;
            break;
        case 1:
            rowHeight = 300;
            break;
        default:
            rowHeight = <your default value>;
            break;
    }

    return rowHeight;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-19
    • 2010-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多