How can I disable the selection effect when selecting a particular UITableViewCell
?
You need to set the selectionStyle property on the cell: cell. selectionStyle = UITableViewCellSelectionStyle. None in Swift, or cell.
Inside the cellForRowAt indexPath method, on the table view cell, set the selectionStyle to . none .
deselectRow(at:animated:) Deselects a row that an index path identifies, with an option to animate the deselection.
A view that presents data using rows in a single column. iOS 2.0+ iPadOS 2.0+ Mac Catalyst 13.1+ tvOS 9.0+
in tableView:cellForRowAtIndexPath:
method
use this
cell.selectionStyle = UITableViewCellSelectionStyleNone
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 job is done by setting:
cell.selectionStyle = .none
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With