在表格视图中创建单元格时,我运行了以下代码
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    Medicine *medicine = [self.fetchedResultsController objectAtIndexPath:indexPath];
    if ([medicine isDue] == 1)
    {
        [cell setBackgroundColor:[self dueColour]];
        NSLog(@"Due");
    }
    else if([medicine active] == [NSNumber numberWithInt:0])
    {
        [cell setBackgroundColor:[self inactiveColour]];
        NSLog(@"Inactive");
    }
    else
    {
        [cell setBackgroundColor:[UIColor whiteColor]];
        NSLog(@"Active");
    }
    [[cell textLabel] setText:[medicine name]];
    [[cell detailTextLabel] setText:[NSString stringWithFormat:@"Next Due: %@",[medicine nextDueDate]]];
}
这很好,但是如果我更改问题或活动属性,我希望获得新的单元格颜色,但我得到的是新的单元格颜色,但旧颜色作为文本突出显示,我无法弄清楚为什么。我知道分配了正确的颜色,就像打印出到期的药物和我得到的活性药物一样
2013-09-17 23:05:28.121 Medicine Tracker[11611:907] 截止日期为 2013-09-17
23:05:28.124 医学追踪器[11611:907] 激活
这是正确的,但给出了错误的颜色
这是一张可能更好地说明我的意思的图片