1

I have a vertical UICollection view. One of it cells has a table view.
The table view size has it content size, this means there is no scrolling for table view.
The problem is once the collection view cell that has the table view being displayed, all the table view cells loaded. Which means no reusing for the table view cells. since they all loaded.

I had a 52 cells for the table view, All of them loads at the same time on the memory. this makes the app freezing.

I did a debug for the table view datasource call back, the cellForRowAtIndex method is called once for each table view cell at first time. And it doesn't called when scrolling down to see table view cells; This leads me to recognize that there is no reusing for TableViewCells.

Any help?

Ahd Radwan
  • 1,090
  • 4
  • 14
  • 31
  • Please add UI image of your output or your expected output. May be here you get better approach. – dahiya_boy Feb 23 '17 at 06:36
  • 1
    Why do you need to embed a table view into a collection view? Can't you just display whatever tableview data you have in the collection view? – almas Feb 23 '17 at 06:37
  • Why do you need to load all the cells at once to the table? You can (and should) use reusable cells within collection view cell. – Fahri Azimov Feb 23 '17 at 06:50
  • @FahriAzimov I Don't want to load all of them together, but the problem that when the collection view cell being visible. all the table view cells are treated as visible, so there is no reusing. All cells loaded when the collection view cell displayed, How can enable reusing? – Ahd Radwan Feb 23 '17 at 07:20
  • What does your tableview display? 52 rows of giant images loaded synchronously from a URL or local disk? If it's just 52 text cells, I don't see how your app can freeze. – Zhang Feb 23 '17 at 07:59
  • @Zhang it loads 52 cells that has text and local images, but the problem is that it loads all the cells together, this means all the cells are loaded int memory. – Ahd Radwan Feb 23 '17 at 08:06
  • @AhdRadwan in your `cellForRowAt` method of your `tableView` are you using `tableView.dequeReusableCell` when instantiating a new `UITableViewCell`? – Stefan Stefanov Feb 23 '17 at 08:46
  • @StefanStefanov yes of course. The problem that it loads 52 cells at once. There is no way to reuse, all the cells are loaded together, – Ahd Radwan Feb 23 '17 at 08:57

0 Answers0