作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已按升序对数组进行排序。我需要显示要着色的表格的第一个值。我该怎么做
我的代码是:
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/
我是一名优秀的程序员,十分优秀!