简体   繁体   English

TableView里面的TableView ios

[英]TableView inside Tableview ios

I am using tableview inside tableview cell.我在 tableview 单元格中使用 tableview。 My main tableview is using Array1 to make no of rows and inside each row there is another tableview.我的主 tableview 使用 Array1 来制作行数,并且在每一行内都有另一个 tableview。 now i have two different arrays Array2 and Array3.现在我有两个不同的 arrays Array2 和 Array3。

How to populate data from Array2 for main tableview cell0 and populate data from Array3 for main tableview cell1?如何从 Array2 为主 tableview cell0 填充数据,并从 Array3 为主 tableview cell1 填充数据?

Let's say tableView1's first cell is Cell1, Second cell is Cell2假设tableView1的第一个单元格是Cell1,第二个单元格是Cell2

Cell1 have tableView2 and Cell2 have tableView3 Cell1 有 tableView2 和 Cell2 有 tableView3

1) In cellForRowAt of tableView1, reload the child table that it contains. 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) Implement respective DataSource and delegates in Cell1 and Cell2. 2) 在 Cell1 和 Cell2 中实现各自的 DataSource 和委托。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM