[英]TableView inside Tableview ios
我在 tableview 單元格中使用 tableview。 我的主 tableview 使用 Array1 來制作行數,並且在每一行內都有另一個 tableview。 現在我有兩個不同的 arrays Array2 和 Array3。
如何從 Array2 為主 tableview cell0 填充數據,並從 Array3 為主 tableview cell1 填充數據?
假設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 和委托。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.