如何从故事板返回自定义单元格高度?

时间:2014-02-18 18:28:42

标签: ios objective-c uitableview

之前我在how to hide a static cell上提出了一个问题。

Best answer我隐藏了我想要的单元格,但随后它将其他单元格高度设置为44

我想找到一种方法来返回故事板提供的高度,因为不同的单元格可能有不同的高度。

我的表视图也是分组的,静态的,以及许多部分,如果这有助于使它更清晰。

我试过这个

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 5 && image==nil && [indexPath section] == 1){
        NSLog(@"hide cvell");
        return 0;
    }
    return tableView.rowHeight;
}

似乎return tableView.rowHeight;也会返回44,所以没有变化:(


简而言之,这是我需要帮助的地方;

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 5 && image==nil && [indexPath section] == 1){
        NSLog(@"hide cvell");
        return 0;
    }
    return WhatEverSizeFromStoryboard;
}

1 个答案:

答案 0 :(得分:3)

如果它是一个静态单元格,你应该能够使用超类的实现来获得它:

return [super tableView:tableView heightForRowAtIndexPath:indexPath];