点击 tableViewCell 时 UIAlertContro

2018-03-30  本文已影响7人  Desmond_

之前项目中一直存在这个问题,今天特意找了下资料,很多都说是 cell 的 selectionStyle 设置成 none 造成的,改成 default 就可。试了下发现确实是,但这样的话 cell 就会有默认的选中背景色。

找到一个方法,可以这么做:

/// UITableViewDelegate
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        DispatchQueue.main.async {
            UIAlertController.showAlert("\(indexPath.row)")
        }
    }
上一篇 下一篇

猜你喜欢

热点阅读