gpt4 book ai didi

ios - 在 iOS 7 中更改 uitableviewcell 的背景颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:45:18 26 4
gpt4 key购买 nike

自升级到 iOS7 后我遇到了一个问题,当我尝试更改特定 tableview 单元格的背景颜色时,它不会为正确的单元格着色(通常是指定的单元格和其他单元格) .从下面的代码中可以看出,我定义了要突出显示的类型,然后更改了颜色。它在 iOS 升级之前运行良好,所以我不确定是什么改变导致了这个问题:

快速编辑:另外,当我向下滚动 tableview 然后向上滚动时,它会为更多在 tableview Controller 首次加载时没有着色的单元格着色(如果这有帮助的话)。

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
NSString* type=[[self.HandPointer.player_hand objectAtIndex:indexPath.row]cardType];
if ([type isEqualToString:@"ace"]){
cell.backgroundColor = [UIColor colorWithRed:0.81 green:0.91 blue:0.81 alpha:1.0];
}
}

最佳答案

我认为在 tableView: cellForRowAtIndexPath: 方法中自定义单元格更好。在这个方法中,

if ([type isEqualToString:@"ace"])
{
cell.backgroundColor = [UIColor aceColor];
}
else // this else is important. If you add this, scrolling works fine.
{
cell.backgroundColor = [UIColor otherCellColor];
}

关于ios - 在 iOS 7 中更改 uitableviewcell 的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19099438/

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