我为我的 uitableviewcell 创建了 Xib 文件,在属性检查器中,我选择了默认的 SelectionStyle,但这并没有帮助我。所以我添加了附件类型.detailDisclosureButton。所以当我点击一个单元格时,我的单元格并没有高亮显示灰色,只有披露按钮显示灰色。
也许你可以试试这个。
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
}
}