之前项目中一直存在这个问题,今天特意找了下资料,很多都说是 cell 的 selectionStyle 设置成 none 造成的,改成 default 就可。试了下发现确实是,但这样的话 cell 就会有默认的选中背景色。
找到一个方法,可以这么做:
/// UITableViewDelegate
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
DispatchQueue.main.async {
UIAlertController.showAlert("\(indexPath.row)")
}
}
网友评论