我使用的核心數據和MagicalRecord管理項目,它可以是啓用或禁用。有 和已啓用標記項目實體在Data Store中。一個項目也有一個標題。最後,使用NSFetchedResultsController
,我在 的表格視圖中顯示項目。表格視圖有兩個 部分:第一個用於啓用項目,第二個用於禁用項目。全部項目 爲默認啓用。 禁用項目的單元具有不同的背景顏色(黃色)。 要多一點複雜的事情,細胞從榫文件加載像這樣:的UITableViewCell從筆尖沒有更新加載(緩存?)
- (void)viewDidLoad
{
// ...
self.items = [Item fetchAllGroupedBy:@"enabled"
withPredicate:nil
sortedBy:@"enabled,createdOn"
ascending:NO
delegate:self];
// ...
[self.tableView registerNib:[UINib nibWithNibName:@"CustomTableViewCell" bundle:nil]
forCellReuseIdentifier:@"CustomCellReuseIdentifier"];
// ...
}
// ...
- (CustomTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseIdentifier = @"CustomCellReuseIdentifier";
CustomTableViewCell *cell =
(CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:reuseIdentifier
forIndexPath:indexPath];
[self configureCell:cell forRowAtIndexPath:indexPath];
return cell;
}
- (void)configureCell:(CustomTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
Item *item = [self.items objectAtIndexPath:indexPath];
cell.titleLabel.text = item.title;
if (!item.enabled.boolValue) {
cell.backgroundColor = [UIColor colorWithRed:0.999 green:0.895 blue:0.452 alpha:1.000];
}
}
// ...
現在,當我禁用的項目,刪除,然後創建新項目具有相同標題,則 新項目的細胞有一個黃色背景,即使新項目是啓用。如果我檢查項目 本身,它確實啓用,所以它只是保持黃色的單元格。
有人知道這個問題可能是什麼嗎?
啊!來自我的愚蠢的錯誤...非常感謝!目前無法接受答案,您發佈速度太快! –