TableView inside Tableview ios



我在tableview单元格中使用tableview。我的主表视图使用Array1不生成任何行,并且在每一行中都有另一个表视图。现在我有两个不同的数组Array2和Array3。

如何从Array2为主表视图单元格0填充数据,从Array3为主表查看单元格1填充数据?

假设tableView1的第一个单元格是Cell1,第二个单元格是Cell2

单元格1具有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和委托。

最新更新