swift - Tableview里面的TableView ios
问题描述
我在 tableview 单元格中使用 tableview。我的主 tableview 使用 Array1 来制作行数,并且在每一行内都有另一个 tableview。现在我有两个不同的数组 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 和委托。
推荐阅读
- java - 编写一个程序,返回数组中大于 11 的前 3 个数字,然后返回你找到的数?
- c++ - 通过引用调用与通过指针参数调用 todo pre 和 postincrement 的区别
- html - 如何在css中正确地将div彼此相邻?
- javascript - 悬停后永久显示图像的颜色
- playframework - 无法创建 play_evolutions 表
- amazon-web-services - 在 AWS 上托管静态网页时,如何让我的电子邮件注册表单正常工作?
- node.js - 将脚本标记添加到 Sabre 静态站点生成器时出错
- css - 如何防止孩子继承 3d 转换 CSS3?
- flutter - 如何使颤振小部件的一部分表现得像堆栈
- android - 如果我给出像文件夹名称/图片名称这样的图像路径,它会显示在 windows 平台上,但不会在 xamarin 中的 Android 中显示