委托方法来设置单元格文本颜色

时间:2016-07-15 22:11:45

标签: ios objective-c uitableview

我希望在委托将信息传回时设置所选表格视图单元格的文本颜色。

这就是我所拥有的:

-(void)reSelectTableRow:(NSUInteger)index{
    if(index < albumTracksArrayForTVC.count){
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
        [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:
         UITableViewScrollPositionNone];
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
        cell.textLabel.highlightedTextColor = [UIColor greenColor];
        cell.textLabel.textColor = [UIColor redColor];
    }
    NSLog(@"Delegate reSelectTableRow was called");
    [self.tableView reloadData];
}

但是,我的尝试(cell.textLabel.highlightedTextColor = [UIColor greenColor];cell.textLabel.textColor = [UIColor redColor];)似乎都无效。

有什么想法吗?

以下是我最初在cellForRowAtIndexPath cell.textLabel.highlightedTextColor = [UIColor brownColor];中设置突出显示的文字的方式。

0 个答案:

没有答案