当我单击表格视图内的复选框时,一个标签内的数量应添加到iOS中的另一个标签上

时间:2019-06-26 09:42:53

标签: ios

我在一个tableview中有一个复选框和标签,当我们单击checkbox时,tableview的每个单元格中标签中的价格应添加到另一个视图中的另一个标签中

@IBAction func checkUncheckButtonAction(_ sender: UIButton) {


    if let cell = sender.superview?.superview as? PrepaidPageTableViewCell
    {

        let indexPath = tableviewOutlet.indexPath(for: cell)

        if cell.checkUncheckButtonOutlet.isSelected == false
        {

            cell.checkUncheckButtonOutlet.setImage(#imageLiteral(resourceName: "checked_blue"), for: .normal)

            cell.checkUncheckButtonOutlet.isSelected = true

            viewHeightConstraint.constant  = 65

            cell.amountOutlet.text = "₹ "+amount_receivable_from_customerArray[indexPath!.row]

              isPrepaidOrder = false

            tableviewOutlet.reloadData()

        } else {

            cell.checkUncheckButtonOutlet.setImage(#imageLiteral(resourceName: "unchecked_blue"), for: .normal)

            cell.checkUncheckButtonOutlet.isSelected = false

            self.viewHeightConstraint.constant = 0

            tableviewOutlet.reloadData()
        }
    }
}

1 个答案:

答案 0 :(得分:0)

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "PrepaidPageTableViewCell") as! PrepaidPageTableViewCell

    cell.customerNameOutlet.text = buyer_nameArray[indexPath.row]
    cell.deliverydateOutlet.text = "Delivery Date:\(dispatch_dateArray[indexPath.row])"
    cell.amountOutlet.text = "₹\(amount_receivable_from_customerArray[indexPath.row])"

    cell.dispatchidoutlet.text = "Dispatch ID: \(id_dispatch_summaryArray[indexPath.row])"
    cell.dispatchdateOutlet.text = "Dispatch Date:\(dispatch_dateArray[indexPath.row])"
    cell.checkUncheckButtonOutlet.setImage(#imageLiteral(resourceName: "unchecked_blue"), for: .normal)

    cell.selectionStyle = .none

    return cell
}