简体   繁体   English

我想使用 Swift 4.2 到 5.1 在 TableView 中选择“其他”单元格时显示另一个单元格

[英]I want to Show another Cell on the Selection of “Other” Cell in TableView using Swift 4.2 to 5.1

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



    let tblContent = tblViewCustomFields[indexPath.row]

    let title = tblContent
    let custmCell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! CustomCellForLetKnowUs

    let customTextCell = tableView.dequeueReusableCell(withIdentifier: "textCell") as! CustomTextCell

    custmCell.lblInfo.text = title
    if indexPath.row == 7 {
        //            cellList.append(.withTxtFld)
        //            tableView.reloadData()
        customTextCell.textView.isHidden = true
    }

    return custmCell

}

Try to do this尝试这样做

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     if indexPath.row == 7 { 
          let customTextCell = tableView.dequeueReusableCell(withIdentifier: "textCell") as! CustomTextCell
          customTextCell.textView.isHidden = true
          return customTextCell
     }


     let custmCell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! CustomCellForLetKnowUs
     custmCell.lblInfo.text = tblViewCustomFields[indexPath.row] ?? ""

     return custmCell
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM