CustomCollectionViewLayout
CustomCollectionViewLayout copied to clipboard
also scroll both two direction even if I set "Direction Lock Enabled"
I find that if you touch fastly and move diagonally, even if I set Direction Lock Enabled
, the table still scroll in both two direction.
any ideas? thanks for you time.
Hi,
The same issue happens for me too. Please help me out.
A collection view will scroll in both directions if the content size of the collection view is larger than the bounds of the screen.
The collection view's content size is determined by the delegate method collectionViewContentSize
.
Here's a quick way to ensure that the collection view does not scroll horizontally. You can copy and paste this into the CustomCollectionViewLayout project.
override func collectionViewContentSize() -> CGSize {
if contentSize.width > UIScreen.mainScreen().bounds.size.width {
contentSize.width = UIScreen.mainScreen().bounds.size.width
}
return contentSize
}
This is for example only. Don't use this in production because it will clip the right edge of the right-most cells.