I have a table view, and I want to know how to change the selected text color of a string, say, to Red? I tried this code:
- (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];
(1) When I select any line, then the text color changes to red, but when I select another, the previously selected line text remains red. how can i solve this?
(2) When I look at the color change of the table text to black, how can I solve this?
Thank..
ios objective-c iphone uitableview
Maulik Apr 30 '11 at 10:13 2011-04-30 10:13
source share