[swift4] How to disable TableView Tap on each TableView Cell
How to disable TableView Tap on each TableView Cell, is below code
Setup Cell for un-selected(gray) with tap
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) if indexPath.row == 1 { // Disable Selected Color evenif tapped cell.selectionStyle = UITableViewCellSelectionStyle.none } return cell }
Setup not to pass indexPath info to didSelectRowAt evenif tapped
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { switch indexPath.row { case 0: return indexPath; // if nil, indexPath info won't be passed to didSelectRowAt method case 1: return nil; default: return indexPath; } }