簡體   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

}

嘗試這樣做

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