나는 tableview를 가지고 있는데, 내가 선택한 행의 텍스트 색을 어떻게 변경할 수 있습니까? 그때 어떤 행을 선택하면 UITableViewCell 선택된 행의 텍스트 색 변경
- (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) 텍스트 색상이 빨간색으로 변경하지만 선택하면 다른 한 후 이전에 선택한 행의 텍스트는 빨간색으로 유지 :이 코드에 의해 시도했다. 어떻게 해결할 수 있을까요?
(2)이 문제를 해결하려면 검은 색으로 테이블 텍스트 색 변경을 스크롤 할 때?
감사합니다 ..
다른 행을 선택하기 전까지는 색상이 빨간색이어야합니다! – Maulik
진짜야 .... 푸른 색도 남아 있습니다 !!! – Maulik
헤이 작동 괜찮아요, 고마워. –