how to reload a collectionview that is inside a tableviewcell

uicollectionview reloaddata
uicollectionview bottom refresh control swift
reload collection view with animation swift
table view inside collection view cell
uicollectionview reloaddata blink
uicollectionview update cell
uicollectionview not reloading
uicollectionview reloaddata(completion)

I have a collectionView inside a tableViewCell

for example: credit: How to use StoryBoard quick build a collectionView inside UITableViewCell

I would like to reload the collectionView when I update information.

I have put a print in the collectionView's cellForItemAtIndexPath to test if it is being called but it isn't. How can I get the collectionView to reload?

I found out how! In my tableViewCell class I just need to link the collectionView as an outlet so in my tableViewCell's cellForRowAtIndexPath I just needed to call cell.collectionView.reloadData()

In your case, you should assign tag to your collection view in order to get access outside the cellForRowAt function. This is how your function should look like: And each collection view fills an entire table view cell (an entire row of the table view). And then the table view cells are inside the table view (again, just like normal). OK, cool. The only thing that’s odd here is the collection view inside of a table view cell.

Simplest Way

for cell in tableView.visibleCells {
    (cell as? YourTableViewCell)?.collectionView.reloadData()
}

Or If you need to reload Specific UICollectionView

if let cell = tableView.cellForRow(at: IndexPath(row: 0, section: 0)) as? YourTableViewCell {
   cell.collectionView.reloadData()
}

Subclass UITableViewCell and add the methods and a reference to its collection view. Handle your calls there. I'm assuming you made the  Manage Custom UICollection View in UITableview Cell in swift 3 Custom Layout Sometimes we have taken the multiple UICollectionView in a different cell of UITableView and each cell has a different size so for managing this thing we use autoresizing in UItableview.

create tags for collection view with indexPath.row of UITableView and create an instance of the UICollectionView using the tag and reload !

A few years ago, I wrote this post on putting a collection view inside a to reloadData() – take a look at their GitHub issue for a discussion why.). TableViewCell. The TableViewCell does the magic. It has an outlet to your collectionView, enables the auto layout for collectionView cells using estimatedItemSize of the UICollectionViewFlowLayout. Then, the trick is to set your tableView cell's size at the systemLayoutSizeFittingSize method. (NOTE: iOS8 or later)

1st on tableview cell create this function:

func collectionReloadData(){
        DispatchQueue.main.async(execute: {
            self.collectionView.reloadData()
        })
    }

then call it from

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { ...

    cell.collectionReloadData()

For efficiency, the collection view only displays those cells and supplementary views that are visible. If the collection data shrinks as a result of the reload, the  Detecting which cell is tapped and passing the data. To detect which cell is tapped, go to TableViewCell and create a protocol with a name CollectionViewCellDelegate and inside there add a method that returns the cell ( CollectionViewCell ), the position ( index) of this cell, and which TableViewCell is tapped.

The collection view gets its data from the data source object, which is an object that and location of all cells and supplementary views inside the collection view​. Animates multiple insert, delete, reload, and move operations as a group. CollectionView Inside TableView Cell in Swift 3 - Duration: 16:14. Divyesh Gondaliya 6,885 views. 16:14. JAVA - How To Design Login And Register Form In Java Netbeans - Duration: 44:14.

2: Now register the UICollectionView and their properties in before reload call. 3: Now define the UITableViewCell class: 1. 2. 3. 4. Update : I've re-written this tutorial using storyboards and Swift – check it out ! So you want to put a collection view inside of a table view cell, eh? Sounds easy, right? Well, to do it right requires a little bit of work. We want a clear separation of concerns so that the UITableViewCell isn't acting as the data…

In Most of time we use the collection view inside the table view cell if the collection view flow class ProductTableViewCell: UITableViewCell {. I am building a layout in which i have to show airplane seats (grid layout) so i have used collectionView inside tableView, but the problem is that once data is fetched and passed to the vc and the tableview reloads, some of the rows with the collectionview appears to be blank/white boxes.

Comments
  • I'm voting to close this question as off-topic because its not really an issue as "i just needed to call cell.collectionView.reloadData()"
  • After I added cell.collectionView.reloadData(), CollectionView scrolling is so slow in my project. How to solved that kind of problem.
  • I am also facing the same problem. How can we fix slow scrolling?
  • Try the following on the collection view - invalidateLayout and layoutIfNeeded