首页 > 解决方案 > 从其他表格 DidSelect 方法更新表格单元格数据

问题描述

我有一个UITableViewwithUITexField里面有两个。和里面Second UITableViewtwo UILabel

检查图像。

在此处输入图像描述

现在想要当用户单击Add Button. Menu popUp with a table View(称为tblPassList) 现在,当用户选择 RowName并将Age更新到该特定单元格时。

这是我所做的,但仅在 First Cell.Check 图像上更新。在此处输入图像描述

变量名称2 =“”

变种年龄2 =“”

  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            var cellToReturn = UITableViewCell()
            if tableView == tblOnWard {
                let Cell = tableView.dequeueReusableCell(withIdentifier: "TblOnward", for: indexPath) as! TblOnward
                Cell.selectionStyle = .none
                Cell.shawdow(viewShadow: Cell.ViewCell)
                Cell.lblSeatNo.text = "Seat No. " + arrSeatNoOnward[indexPath.row]
                Cell.lblHead.text = ArrHeadTitle[indexPath.row]
                Cell.txtName.text =  self.name2
                Cell.txtAge.text = self.age2
                self.age2 = ""
                self.name2 = ""
                cellToReturn = Cell
            }
           return cellToReturn
}

选择

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if tableView == tblPassList {
            let cell = tableView.cellForRow(at: indexPath) as! GetpassList
            name2 = cell.lblName.text!
            age2 = cell.lblAge.text!
            self.tblReturn.reloadData()
            self.tblOnWard.reloadData()
        }
    }

有什么建议吗?

标签: iosswiftuitableview

解决方案


推荐阅读