I have developed a tvOS application that renders a CollectionView inside of a CollectionView. Each section of the first CollectionView has only 1 element, let's call it RowCell, and this element contains the second CollectionView, that has many cells of that given category.
The problem I have is:
when I use .reloadData() in the prepareForReuse method in the RowCell (the row that contains the cells separated by categories) it loads extremely slow when I scroll up and down. And if I don't use .reloadData() for the RowCell, the data always get rendered wrong.
Any thoughts about how to use .reloadData() and don't decrease scrolling/rendering speed.
Thanks in advance.
It seems that if you have many categories, you're doing a lot of
reloadData(). That gets worse if the inner collection view's cells requires hard work to be rendered, despite of cell reusing. To mitigate that, you may want to take a look in Prefetching Collection View Data, where you can prefetch required data and perform hard work asynchronously for cells before they actually display.Also, if that's possible, I suggest you to take a look in IGListKit, a third-party library developed by Instagram that claims to be a tool for building
flexibleandfastlists. I myself used IGListKit and it is, indeed, a really good option for creating the kind of collection view you want. The problem is that its learning curve can be steep.Hope this helps!