【发布时间】:2017-08-06 13:33:00
【问题描述】:
我想在不使用库的情况下使用自定义单元格在索引路径的行中添加一个子行。
当我选择一个单元格时,另一个单元格出现在这个单元格下方,这个操作对每个单元格重复 Ps:它会出现的单元格是一样的
我试试这个:
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayEnum.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var CellTB: UITableViewCell!
let cell = tableView.dequeueReusableCell(withIdentifier: "enumCell", for: indexPath)as! UserFlagTableViewCell
cell.UserflagLabel.text = arrayEnum[indexPath.row].rawValue
CellTB = cell
// let cell1 = tableView.dequeueReusableCell(withIdentifier: "freeTextCell", for: indexPath)as! FreeTextTableViewCell
// cell1.sendButton.addTarget(self, action: Selector("sendUserflagEvent:"), for: .touchUpInside)
// CellTB = cell1
return CellTB
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.tableView.insertRows(at: [IndexPath(row: UserFlagType.userFlagTypes.count-1, section: 0)], with: .automatic)
self.tableView.beginUpdates()
self.tableView.endUpdates()
}
我有 1 个部分 我有 6 行
【问题讨论】:
标签: ios uitableview swift3 expand