user440096
user440096

Reputation:

Stopping a table cell highlighting on selection,

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

Upvotes: 2

Views: 672

Answers (2)

SPA
SPA

Reputation: 1289

You can also specify the cell selection as none, blue or gray in the attributes inspector in xcode

enter image description here

Upvotes: 2

IronManGill
IronManGill

Reputation: 7226

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];       
}

Upvotes: 4

Related Questions