当当前日期 == Facebook 生日列表日期时,我正在尝试更改text color
单元格中的标签。
在cellForRowAtIndexPath:
id 中这样做了
if([curdatemonthstring isEqualToString:[[totalbirthlistArray objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]])
{
[nameLabel setTextColor:[UIColor purpleColor]];
}
这可以改变颜色,但是当我滚动它时它会变回旧颜色。我怎样才能解决这个问题?
-(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]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];
}