Reloading TableView from CollectionViewCell

心不动则不痛 提交于 2019-12-12 16:17:45

问题


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()

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!

Thanks in advance!


回答1:


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()


来源:https://stackoverflow.com/questions/41269300/reloading-tableview-from-collectionviewcell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!