Я пытаюсь изменить text color
метки в клетке, когда Current Date == Facebook День рождения Список дат.Изменение цвета текста UILabel в UITableViewCell
В cellForRowAtIndexPath:
ид сделал это
if([curdatemonthstring isEqualToString:[[totalbirthlistArray objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]])
{
[nameLabel setTextColor:[UIColor purpleColor]];
}
Это работает, чтобы изменить цвет, но когда я прокручиваю его изменения назад к старому цвету. Как я могу это исправить?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *[email protected]"SimpleTableItem";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:simpleTableidentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableidentifier]autorelease];
}
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[[[cell contentView] subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
contentview = [[[UIView alloc]init] autorelease];
[contentview setFrame:CGRectMake(0, 0,320,80)];
//Display Friends Name
nameLabel = [[[UILabel alloc] init]autorelease];
[nameLabel setBackgroundColor:[UIColor clearColor]];
[nameLabel setFrame:CGRectMake(76, 5, 200, 45)];
[nameLabel setFont:[UIFont fontWithName:@"Politica" size:20]];
[nameLabel setText:[[[monthdataArray objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]objectForKey:@"name"]];
if([curdatemonthstring isEqualToString:[[totalbirthlistArray objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]])
{
[nameLabel setTextColor:[UIColor purpleColor]];
}
[contentview addSubview:nameLabel];
[cell.contentView addSubview:contentview];
return cell;
[birthdaylist reloadData];
}
просьба представить полный код. –
Я думаю, что вы написали его в условии if (cell == nil) – SRI
Конкретно покажите, где вы создаете ячейку, цвет сбрасывает его, скорее всего, потому что ячейка создается неправильно. –