gpt4 book ai didi

ios - 如何从 Storyboard 返回自定义单元格高度?

转载 作者:行者123 更新时间:2023-12-01 18:16:01 25 4
gpt4 key购买 nike

早些时候我在 how to hide a static cell 上问了一个问题。 .

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

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

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

我试过这个

- (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;
}

最佳答案

如果它是一个静态单元格,您应该能够使用父类(super class)的实现来获得它:

return [super tableView:tableView heightForRowAtIndexPath:indexPath];

关于ios - 如何从 Storyboard 返回自定义单元格高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21862380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com