我有一个tableview,我想知道如何更改所选行的文本 colored颜色 ,比如红色?我try 了以下代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell= [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease];
cell.text = [localArray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
cityName = [localArray objectAtIndex:indexPath.row];
UITableViewCell* theCell = [tableView cellForRowAtIndexPath:indexPath];
theCell.textColor = [UIColor redColor];
//theCell.textLabel.textColor = [UIColor redColor];
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
(1) 当我 Select 任何一行时,文本 colored颜色 变为红色,但当我 Select 另一行时,之前 Select 的行的文本仍为红色.我该怎么解决这个问题?
(2) 当我滚动表格文字 colored颜色 变为黑色时,如何解决这个问题?
谢谢