ios - 我想使用 Swift 4.2 到 5.1 在 TableView 中选择“其他”单元格时显示另一个单元格
问题描述
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
}
推荐阅读
- android - 按钮的背景属性不起作用
- reactjs - 如何使用 react 和 typescript 使用 usecontext?
- javascript - 在 jQuery 中从 php 解析 json
- sql - 在 Spark SQL 中创建临时视图
- python - 如何使用 Python 将 csv 的第一行替换为标题?
- angular - Angular App 无法与 Nginx Docker 容器中的 API 通信
- visual-studio - 找出 Visual Studio 使用的 Windows SDK
- reporting-services - SSRS 不良结果
- javascript - 无法读取未定义的属性 myFunction
- python - 有没有办法改变普通代码或文本的特定字符的颜色