繁体   English   中英

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

[英]How to return custom cell height from storyboard?

早些时候我问了一个关于如何隐藏静态细胞的问题

我得到的最佳答案隐藏了我想要的单元格,但随后它将其他单元格高度设置为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;
}

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

return [super tableView:tableView heightForRowAtIndexPath:indexPath];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM