Tengo una vista de tabla y quiero saber cómo puedo cambiar el color del texto de la fila seleccionada, por ejemplo, a Rojo? He intentado por este código:UITableViewCell cambio de color del texto de la fila seleccionada
- (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) Cuando selecciono cualquier fila a continuación, el color del texto cambia a la roja, pero cuando selecciono el texto de otra fila a continuación, previamente seleccionada permanece en rojo. Como puedo resolver esto ?
(2) Cuando me desplazo por la tabla, el color del texto cambia al color negro ¿cómo solucionarlo?
Gracias ..
¡el color debe ser rojo hasta que seleccione otra fila! – Maulik
ya cierto ... ¡el color azul también permanece! – Maulik
Oye, funciona bien, gracias. –