gpt4 book ai didi

ios - 如何隐藏 UITableViewCell?请看截图

转载 作者:行者123 更新时间:2023-11-29 04:55:17 24 4
gpt4 key购买 nike

我需要隐藏一个 UITableViewCell。我将背景颜色设置为清除,但单元格仍然可见。请查看屏幕截图。

cell.backgroundColor = [UIColor clearColor];

enter image description here

最佳答案

通常情况下,你不会这样隐藏它。相反,您应该尝试根本不显示它。在 TableView Controller 的 numberOfRowsInSection 方法中,尝试如下操作:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//... code regarding other sections goes here

if (section == 1) { // "1" is the section I want to hide
if (self.cellShouldBeVisible) {
return 0; // show no cells
} else {
return 1; // show one cell
}
}
}

(当然,您可以用自己的代码替换 self.cellShouldBeVisible )

如果您想从显示单元格变为不显示单元格,请将 self.cellShouldBeVisible 设置为所需的 BOOL 值并调用 [self.tableView reloadData];

关于ios - 如何隐藏 UITableViewCell?请看截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8121786/

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