2

When a table cell is selected it gets highlighted in a blue color. I'd like to prevent this happening.

I tried doing this

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{    
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}

But it goes blue for a second before the blue disappears. Is there a way I can avoid it appearing blue? I'd like to do something custom to the table cell instead.

Many Thanks, -Code

4

2 回答 2

4

UITableViewCell has three selection styles:-

  1. Blue

  2. Gray

  3. None

Implementation is as follows:-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath {

     [cell setSelectionStyle:UITableViewCellSelectionStyleNone];       
}
于 2012-10-13T10:35:52.447 回答
2

您还可以在 xcode 的属性检查器中将单元格选择指定为无、蓝色或灰色

在此处输入图像描述

于 2012-10-13T10:45:57.813 回答