gpt4 book ai didi

ios - 滚动时在 UITableViewCell 中隐藏 UILabel

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

我正在使用 UITableView 来显示数据。我在每个单元格内放置了 1 个 UILabel。我想在滚动时隐藏这些 UILabel。我试过这个,但什么也没发生。

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
homeButton.userInteractionEnabled = NO;
HomeCell *cell = [[HomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.timeLeft.hidden = YES;
}

谢谢。

最佳答案

我会使用 NSNotification为了这。

HomeCell awakeFromNib 中的类方法做...

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLabel) name:@"ShowLabelsInCells" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hideLabel) name:@"HideLabelsInCells" object:nil];

然后创建方法 showLabelhideLabel .

然后在 UITableViewController您可以观看 ScrollView 滚动(和停止滚动)并调用...
[[NSNotificationCenter defaultCenter] postNotificationName:@"ShowLabelsInCells" object:nil];

和...
[[NSNotificationCenter defaultCenter] postNotificationName:@"HideLabelsInCells" object:nil];

当你需要它们时。

无需遍历单元格。

关于ios - 滚动时在 UITableViewCell 中隐藏 UILabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18051940/

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