Как сделать стиль выделения в UITableViewCell - PullRequest
0 голосов

Я создал файл Xib для моей uitableviewcell в атрибутированном инспекторе. Я выбрал SelectionStyle по умолчанию, но мне это не помогло. Итак, я добавил тип аксессуара .detailDisclosureButton. Поэтому, когда я нажимал на ячейку, моя ячейка не выделялась серым цветом, только кнопка раскрытия делает

enter image description here

enter image description here

1 Ответ

0 голосов
/ 29 мая 2020

Может быть, вы можете попробовать это,

extension CWScoreBoardViewController: UITableViewDelegate {

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      tableView.deselectRow(at: indexPath, animated: true)
  }

}

, или вы можете попробовать это,

extension CWScoreBoardViewController: UITableViewDataSource {

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

      cell.selectionStyle = .none

      return cell
  }

}

...