为自定义的AccessoriesView TableViewCell添加操作

时间:2018-10-03 20:31:02

标签: swift uitableview

我尝试为单元格添加自定义accesoryView,并且做到了,但是我不明白如何在该按钮调用函数中获取indexPath.row!

在#selector中,我无法传输签名中的索引

我的细胞鳕鱼

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! NewMessageTableViewCell
        cell.userData = searchUsers[indexPath.row]
        cell.addButton.addTarget(self, action: #selector(printHello), for: .touchUpInside)
        cell.accessoryView = cell.addButton
        return cell
    }

0 个答案:

没有答案
相关问题