这篇文章在我的TableView中给出了奇怪的结果。我希望为键"标记"="是"的重新对象值的单元格显示UIImage
。
正确的代码是什么?
if ([[[sortedObjects objectAtIndex: indexPath.row] valueForKey:@"Marked"] isEqual:@"Yes"])
{
cell.markedImageView.image = [UIImage imageNamed:@"markedItem.png"];
}
问题是每次重复使用单元格时都需要清除 imageView 图像。
- (void)configCell:(MyCustomCell *)cell atIndexPath:(NSIndexPath)indexPath
{
cell.markedImageView.image = nil;
// configure cell normally
if ([[[sortedObjects objectAtIndex: indexPath.row] valueForKey:@"Marked"] isEqual:@"Yes"])
{
cell.markedImageView.image = [UIImage imageNamed:@"markedItem.png"];
}
}