1 year ago

#74063

test-img

Reckoner

Scrolling issue in collectionView reusable cells

Scenario
I have a horizontal collection view with each cell holding a vertical collection view. So basically its an array of products wherein:

  1. Horizontal collection view has a datasource of [Product] objects.
  2. Vertical collection view(which is inside the cell of horizontal collection view) shows the details of that particular product.

Issue
Now the issue is that, let's say, whenever I scroll the first product vertically to some offset to see its details and then goto fourth product(by scrolling horizontally), it shows me scrolled to the same offset as first product due to reusability of cells.

Possible solutions I tried

  1. Tried resetting the contentoffset to 0 in prepareForReuse().
  2. Stored the offsets for each product in an array and then set the offset using willDisplayCell. This solves the offset problem but some components don't load on some products till I scroll a bit.

Any ideas how can I solve this problem?

ios

swift

uicollectionview

0 Answers

Your Answer

Accepted video resources