Disable selection effect when selecting UITableViewCell

How to disable the selection effect when selecting a specific UITableViewCell ?

+7
ios objective-c iphone cocoa-touch xcode
source share
7 answers

in tableView:cellForRowAtIndexPath: method

use this

cell.selectionStyle = UITableViewCellSelectionStyleNone

+21
source share

Swift 3.0

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) as! UITableViewCell cell.selectionStyle = .none return cell } 

The task is performed by installation:

cell.selectionStyle = .none

+3
source share

There is a delegate method for setselectionstyle for none.Once this set table reload gives the desired effect.

+2
source share

you can use:

 cell.selectionStyle = UITableViewCellSelectionStyleNone; 
+2
source share

you can use cell.selectionStyle = UITableViewCellSelectionStyleNone;

or

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

in cellForRowAtIndexPath dataSource method

0
source share

Write this to the didSelectRowAtIndexPath:index method,

cell.selectionStyle = UITableViewCellSelectionStyleNone

OR

[self.tblName deselectRowAtIndexPath:indexPath animated:NO];

0
source share

In Swift 4.5 / 5.0

 cell.selectionStyle = UITableViewCell.SelectionStyle.none 

Or,

 cell.selectionStyle = .none 
0
source share

All Articles