从 CollectionViewCell 重新加载 TableView [英] Reloading TableView from CollectionViewCell

查看:19
本文介绍了从 CollectionViewCell 重新加载 TableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何重新加载 CollectionViewCustomCell 内的 TableView? 我有该 TableIBOutlet 和访问的唯一方法Table 位于 cellForItemAtIndexPath 方法中,我可以在其中访问我的 CollectionViewCustomCell 并通过该方法访问 Table.

Does anyone have idea how to reload TableView that's inside of CollectionViewCustomCell? I have an IBOutlet of that Table and the only way to access that Table is inside cellForItemAtIndexPath method where I can access my CollectionViewCustomCell and through that access the Table.

cell.tableViewInsideOfCollectionViewCell.reloadData()

但这仅适用于第一次加载,当我更改 CollectionView 源时,它不会重新加载 TableView.

But this only works on the first load, when I change CollectionView source it will not reload TableView.

如果您需要更多信息,请询问!

If you need anymore info, please ask!

提前致谢!

推荐答案

您可以使用 collectionView.cellForItem(at: IndexPath) 方法获取单元格.然后将其转换为包含 tableView 的单元格类型.现在您可以访问这些单元格属性并可以重新加载 tableView.

You can get the cell using collectionView.cellForItem(at: IndexPath) method. Then cast it to the type of cell that contains the tableView. Now you have access to that cells properties and can reload the tableView.

guard let cell = collectionView.cellForItem(at: IndexPath(row: , section: )) as? CustomCellWithTableView else { return }
cell.tableView.reloadData()

这篇关于从 CollectionViewCell 重新加载 TableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆