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

Falling back to 0 when setting content offset doesn't work when there's contentInset

Open jordanhbuiltbyhq opened this issue 5 years ago • 0 comments

Minor correction. If your collection view has contentInsets for example of UIEdgeInsets(top: 0, left: 24, bottom: 0, right: 24), the contentOffset.x will be -24 initially, so if you fall back to 0 when there's no stored offset that causes it to scroll over inappropriately.

Currently: tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? 0

This is the fix (but requires the collectionView not be private): tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? -tableViewCell.collectionView.contentInset.left

jordanhbuiltbyhq avatar Aug 10 '20 19:08 jordanhbuiltbyhq