【发布时间】:2019-07-16 03:08:18
【问题描述】:
我的项目中有一个可扩展的 tableview 作为我的 tableviewcontroller 的一部分。问题是当表格没有展开时,单元格的其余部分无论如何都会显示,与下一个单元格重叠。我用来创建可扩展表的方法来自本教程:https://dev.to/lawgimenez/implementing-the-expandable-cell-in-ios-uitableview-f7j
我认为他们改变了一些东西,因为这段代码是用旧版本的 xcode 和 swift 编写的。
我已尝试更改单元格和表格视图的某些属性,但到目前为止没有任何效果。
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableViewData[indexPath.row].opened = !tableViewData[indexPath.row].opened
tableView.reloadData()
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if tableViewData[indexPath.row].opened == true {
return 99.5
}
else {
return 40.5
}
}
我希望 tableview 中的单元格在 tableview 中单元格的确切高度处切断自定义单元格,但是当不展开时单元格很小,但所有自定义单元格都被显示并从分配的区域溢出细胞。
【问题讨论】:
标签: swift xcode uitableview