I have a collectionView with compositional layout which scrolls vertically, with each section inside it scrolling horizontally.
I would need to disable bouncing on horizontal scroll, which does not seem to be possible (or maybe I'm doing something wrong?). Disabling vertical bouncing works perfectly.
What I have tried so far:
collectionView.contentInsetAdjustmentBehavior = .never
collectionView.bounces = false
collectionView.alwaysBounceHorizontal = false
collectionView.alwaysBounceVertical = false
collectionView.isDirectionalLockEnabled = true
This does not seem to work for horizontal bouncing - it is still enabled. My compositional layout is created in this way:
func createCompositionalLayout() {
let layout = UICollectionViewCompositionalLayout { sectionIndex, _ in
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(UIScreen.main.bounds.width), heightDimension: .absolute(UIScreen.main.bounds.height))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let group = NSCollectionLayoutGroup.horizontal(layoutSize: itemSize, subitems: [item])
group.interItemSpacing = .fixed(0)
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)
section.orthogonalScrollingBehavior = .paging
return section
}
collectionView.collectionViewLayout = layout
}
If anyone might know how to solve the issue, any help would be much appreciated!