Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable the uitableview highlighting but allow the selection of individual cells

when you tap on a cell the row gets selected and highlighted.Now what i want to do is disable the highlighting but allow the selection.Is there a way around it.There is question that answers this but it disables both the selection and highlighting.

like image 525
soldiershin Avatar asked May 14 '15 09:05

soldiershin


People also ask

How do I turn off cell selection?

You need to set the selectionStyle property on the cell: cell. selectionStyle = UITableViewCellSelectionStyle. None in Swift, or cell.

How can we use a reusable cell in UITableView?

For performance reasons, a table view's data source should generally reuse UITableViewCell objects when it assigns cells to rows in its tableView(_:cellForRowAt:) method. A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse.


1 Answers

You can just set the cell's selection style to "None" from Storyboard:

See here

Or from code:

cell.selectionStyle = UITableViewCellSelectionStyleNone; 

For Swift 3:

cell.selectionStyle = UITableViewCellSelectionStyle.none 

For Swift 4 & above:

cell.selectionStyle = .none 
like image 98
József Vesza Avatar answered Nov 10 '22 02:11

József Vesza