ios7 UITableViewCell selectionStyle won't go back to blue

后端 未结 4 2053
轻奢々
轻奢々 2021-01-30 21:32

Xcode 5.0, iOS 7 and updating an existing app. UITableView selected row is now gray, not blue.

From what I\'ve read they changed the default selection

4条回答
  •  情书的邮戳
    2021-01-30 21:44

    I know I'm really late to the party, but I'll offer my IOS10 work around as well. Don't touch any of your other code, but add:

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.backgroundColor = [UIColor blueColor];
        cell.textLabel.textColor = [UIColor whiteColor];
    
         ... whatever else you do ...
    }
    
    
    -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.backgroundColor = [UIColor whiteColor];
        cell.textLabel.textColor = [UIColor blackColor];
    }
    

提交回复
热议问题