UITableView单元格模糊读取项目

3
我有一个简单的iOS应用程序项目正在进行中。该表格视图显示从网络服务(RSS源)获取的条目,并点击其中一个会跳转到Web视图。
使用以下代码,我检查项目是否已读,如果是,则使用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 我希望单元格模糊以示已读。我在此提供 TechCrunch iPhone 应用程序中的以下图片,作为我所需的示例: enter image description here 提前感谢。
更新:我尝试在 didSelectRowAtIndexPath 中更改文本颜色,但没有成功。
ItemsViewCell *cell = (ItemsViewCell *)[tableView dequeueReusableCellWithIdentifier:@"ItemsCell"];
cell.titleLabel.textColor = [UIColor redColor]; //Red color is just for checking right now

我看不到任何模糊,只有灰色的文本颜色。 - A-Live
@A-Live,你能检查一下更新后的问题吗? - Jessica
它到底是怎么不工作的?你在 cellForRowAtIndexPath/willDisplayCell 中也选择了正确的颜色吗? - A-Live
@A-Live 在Storyboard中默认选择了黑色。 - Jessica
Storyboard 对你标记为已读的 ItemFeed 一无所知,因此当需要时,你必须在初始化/重用单元格时更改标签的颜色。不要忘记将默认颜色设置为如果单元格被重用,则可能具有已读项目的颜色。@Viral 滚动表格。 - A-Live
1
请注意,您正在使用dequeueReusableCellWithIdentifier,@Alexander Merchi提供了正确的替代方案。 - A-Live
2个回答

5
尝试添加以下代码。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
    ItemsViewCell *cell = (ItemsViewCell*)[tableView cellForRowAtIndexPath:indexPath];
    cell.titleLabel.textColor = [UIColor redColor]; //Red color is just for checking right now
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

1
似乎您需要更改单元格中标签的textColor属性,使其颜色类似于Tech Crunch应用程序的textColor。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接