【问题标题】:How to make selection style in UITableViewCell如何在 UITableViewCell 中制作选择样式
【发布时间】:2020-09-16 15:12:14
【问题描述】:

我在属性检查器中为我的 uitableviewcell 创建了 Xib 文件,我选择了默认的 SelectionStyle,但这对我没有帮助。所以我添加了附件类型 .detailDisclosureButton。 所以当我点击一个单元格时,我的单元格没有突出显示灰色,只有显示按钮可以

【问题讨论】:

标签: ios swift uitableview background-color


【解决方案1】:

也许你可以试试这个,

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
  }

}

【讨论】:

    猜你喜欢
    • 2012-08-08
    • 2018-03-04
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-06
    • 1970-01-01
    • 2016-04-08
    相关资源
    最近更新 更多