美文网首页
点击 tableViewCell 时 UIAlertContro

点击 tableViewCell 时 UIAlertContro

作者: Desmond_ | 来源:发表于2018-03-30 14:09 被阅读7次

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

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

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

相关文章

网友评论

      本文标题:点击 tableViewCell 时 UIAlertContro

      本文链接:https://www.haomeiwen.com/subject/duhicftx.html