问题
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