在swift 3中的tableView中按下了哪个单元格按钮

Sae*_*ahi 1 cell uibutton uitableview ios swift3

我已经阅读了类似这样的问题,但这些代码对我没有用,所以请帮助:我有一个表格视图,每个单元格中有一些按钮 - 这个表视图是用户的因素,我添加了按钮到该tableview - 当用户有付费的钱按钮隐藏在那个单元格中的那个因素中,另一个单元格中隐藏另一个因素当用户没有支付付款时没有隐藏 - 这就是我想要检测哪些单元格按钮按下了?!我知道在表视图中我们可以检测到哪个单元格已被按下但是这是不同的,因为用户只需按下该单元格中的按钮不按下所有单元格

由于我的代码太长,我只需将表格视图代码放在这里

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    let cell = tableView.dequeueReusableCell(withIdentifier: "factorCell", for: indexPath) as! FactorCell

    cell.factorTitle.text = factorTitle[indexPath.row]
    cell.factorCode.text = factorCodes[indexPath.row]
    cell.factorDate.text = factorDate[indexPath.row]
    cell.factorHour.text = factorHour[indexPath.row]
    cell.factorPrice.text = factorPrice[indexPath.row]
    cell.factorCondition.text = factorConditions[indexPath.row]
    cell.factorBill.tag = indexPath.row
 cell.factorBill.addTarget(self,action:#selector(factorViewController.Bill), for: UIControlEvents.touchUpInside)

    cell.factorDetail.tag = indexPath.row    

    cell.factorDetail.addTarget(self,action:#selector(factorViewController.FactorDetail), for: .touchUpInside)


    if   factorConditions[indexPath.row] == "?????? ???"  {


        cell.factorBill.isHidden = true


    } else {

        cell.factorCondition.textColor = UIColor.red

        cell.factorBill.isHidden = false

    }


    return cell

}
Run Code Online (Sandbox Code Playgroud)

这是我想要的功能:当用户点击支付他的因子并按下按钮 - 移动到另一个视图控制器并在该视图控制器中,用户可以在该视图控制器中看到这些数据 -

**非常感谢如果你不明白我想做什么告诉我,我会解释更多**

har*_*hav 8

在自定义单元类中为您创建IBAction按钮,然后声明将在按钮单击时调用的块.

var ButtonHandler:(()-> Void)!

    @IBAction func ButtonClicked(_ sender: Any) {
            self.ButtonHandler()
        }
Run Code Online (Sandbox Code Playgroud)

然后在你的tableview类里面的行方法,

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = playlistTableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CustomTableViewCell
        cell.ButtonHandler = {()-> Void in
            // your code 
        }
        return cell
}
Run Code Online (Sandbox Code Playgroud)