gpt4 book ai didi

ios - 如何将第一个值设置为表格颜色

转载 作者:行者123 更新时间:2023-11-28 18:19:54 25 4
gpt4 key购买 nike

我已按升序对数组进行排序。我需要显示要着色的表格的第一个值。我该怎么做

我的代码是:

NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"isDefault"  ascending:NO];
sortedArray = [beneficiariesArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
NSLog(@"This is Sorted Array %@",sortedArray);


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath

{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [[sortedArray objectAtIndex:indexPath.row] objectForKey:@"Fullname"];
return cell;
}

最佳答案

Here it try it in cellForRowAtIndexPath
if(indexPath.row == row number)
{
cell.backGroundColor = [UIColor anycolor]; // set color as you want.
}

在行号中提供您希望显示颜色的值,并在任何颜色类型中提供可用的颜色名称。

关于ios - 如何将第一个值设置为表格颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22498132/

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