从 CollectionViewCell 重新加载 TableView [英] Reloading TableView from CollectionViewCell
问题描述
有谁知道如何重新加载 CollectionViewCustomCell 内的 TableView?
我有该 Table
的 IBOutlet
和访问的唯一方法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屋!