Collection-View-in-a-Table-View-Cell icon indicating copy to clipboard operation
Collection-View-in-a-Table-View-Cell copied to clipboard

Reusing tableview cell

Open FouadAstitou opened this issue 8 years ago • 7 comments

Hi, When scrolling the collectioview inside the cell and then scrolling the tableview, the cell that gets reused shows the the collection view scrolled to the position that i scrolled to in the first cell.

I was assuming that the storedOffsets was for this unwanted behavior. Unfortunately it is not working. Or is the storedOffsets for another issue?

Please help.

FouadAstitou avatar Dec 25 '16 13:12 FouadAstitou

Hmm, good question. The reused cell should have its offset set to zero (as long as it doesn't haven't a preciously stored offset, see this line). I'm not sure what could be causing the issue you're seeing. I'll have a think.

ashfurrow avatar Dec 29 '16 21:12 ashfurrow

Having this issue as well.

danielchristopher1 avatar Feb 04 '17 01:02 danielchristopher1

I had the same issue but fixed it by changing tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? 0 to tableViewCell.collectionViewOffset = storedOffsets[indexPath.section] ?? 0 I hope this helps!

ghost avatar Feb 23 '17 01:02 ghost

Thanks for following up with your solution – it sounds like that would work for a multi-section, single-row table view instead of a single-section, multi-row. Is that the case @ClintonAkins?

ashfurrow avatar Feb 23 '17 04:02 ashfurrow

You're right. This solution is for a mulit-section, single-row UI, like Netfilx, App Store, etc.

ghost avatar Feb 23 '17 04:02 ghost

Fab, thanks again for the follow-up! going to keep this issue open to help people notice :tada:

ashfurrow avatar Feb 23 '17 04:02 ashfurrow

One of the solution that worked for me was setting the contentOffset as

var collectionViewOffset: CGFloat { get { return productCollectionView.contentOffset.x } set { productCollectionView.setContentOffset(CGPoint(x: newValue, y: 0 ), animated: false) } }

anishparajuli555 avatar Dec 19 '17 11:12 anishparajuli555