从 CollectionViewCell 重新加载 TableView

Reloading TableView from CollectionViewCell

有谁知道如何重新加载 CollectionViewCustomCell? 中的 TableView 我有一个 IBOutlet Table 并且访问 Table 的唯一方法是在里面cellForItemAtIndexPath 方法,我可以在其中访问我的 CollectionViewCustomCell 并通过该方法访问 Table.

cell.tableViewInsideOfCollectionViewCell.reloadData()

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

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

提前致谢!

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

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