如何从故事板返回自定义单元格高度? [英] How to return custom cell height from storyboard?

查看:27
本文介绍了如何从故事板返回自定义单元格高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前我问过一个关于如何隐藏静态单元格的问题.

Earlier I asked a question on how to hide a static cell.

最佳答案我根据需要隐藏了单元格,但随后将其他单元格高度设置为 44.

The Best answer I got hides the cell as I wanted but then it sets other cell height to 44.

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

I would like to find a way to return the height provided by the story board since different cell could have different height.

我的表格视图也是分组的、静态的和许多部分,如果这有助于使其更清晰.

also my table view is grouped, static , and many sections if that helps make it clearer.

我试过了

- (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 ,所以没有变化:(

it seems like return tableView.rowHeight; would return 44 also , so no changes :(

简而言之,这是我需要帮助的内容;

to make it short, here is what I need help with;

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

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

推荐答案

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

If it's a static cell, you should be able to get that using the super class' implementation:

return [super tableView:tableView heightForRowAtIndexPath:indexPath];

这篇关于如何从故事板返回自定义单元格高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆