【问题标题】:TableView inside Tableview iosTableview里面的TableView ios
【发布时间】:2020-08-24 13:45:17
【问题描述】:
我在 tableview 单元格中使用 tableview。我的主 tableview 使用 Array1 来制作行数,并且在每一行内都有另一个 tableview。现在我有两个不同的数组 Array2 和 Array3。
如何从 Array2 中为主 tableview cell0 填充数据,并从 Array3 中为 main tableview cell1 填充数据?
【问题讨论】:
标签:
swift
iphone
uitableview
【解决方案1】:
假设tableView1的第一个单元格是Cell1,第二个单元格是Cell2
Cell1 有 tableView2 和
Cell2 有 tableView3
1) 在tableView1的cellForRowAt中,重新加载它包含的子表。
if indexPath.row == 0 {
let cell1 = tableView.dequeueReusableCell(withIdentifier:
“Cell1”,for: indexPath) as! Cell1
-----
//your code
-----
cell1.tableView2.reloadData()
return cell1
} else {
let cell2 = tableView.dequeueReusableCell(withIdentifier: “Cell2”,
for: indexPath) as! Cell2
-----
//your code
-----
cell2.tableView3.reloadData()
return cell2
}
2) 在 Cell1 和 Cell2 中实现各自的 DataSource 和委托。