我有一个简单的iOS应用程序项目正在进行中。该表格视图显示从网络服务(RSS源)获取的条目,并点击其中一个会跳转到Web视图。
使用以下代码,我检查项目是否已读,如果是,则使用setAccessoryType放置一个复选标记来指示该项目已读:
上述代码的结果如下:
我希望单元格模糊以示已读。我在此提供 TechCrunch iPhone 应用程序中的以下图片,作为我所需的示例:
提前感谢。
更新:我尝试在 didSelectRowAtIndexPath 中更改文本颜色,但没有成功。
使用以下代码,我检查项目是否已读,如果是,则使用setAccessoryType放置一个复选标记来指示该项目已读:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ItemFeed *entry = [[channel items] objectAtIndex:[indexPath row]];
[[MyFeedStore sharedStore] markItemAsRead:entry];
[[[self tableView] cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
}
上述代码的结果如下:
![enter image description here](https://istack.dev59.com/Xhj2G.webp)
![enter image description here](https://istack.dev59.com/N8G18.webp)
更新:我尝试在 didSelectRowAtIndexPath 中更改文本颜色,但没有成功。
ItemsViewCell *cell = (ItemsViewCell *)[tableView dequeueReusableCellWithIdentifier:@"ItemsCell"];
cell.titleLabel.textColor = [UIColor redColor]; //Red color is just for checking right now
cellForRowAtIndexPath
/willDisplayCell
中也选择了正确的颜色吗? - A-LiveItemFeed
一无所知,因此当需要时,你必须在初始化/重用单元格时更改标签的颜色。不要忘记将默认颜色设置为如果单元格被重用,则可能具有已读项目的颜色。@Viral 滚动表格。 - A-LivedequeueReusableCellWithIdentifier
,@Alexander Merchi提供了正确的替代方案。 - A-Live