brightec / CustomCollectionViewLayout

Custom layout for a collection view using horizontal and vertical scrolling with sticky rows and columns
MIT License
519 stars 123 forks source link

also scroll both two direction even if I set "Direction Lock Enabled" #8

Open L-Jovi opened 8 years ago

L-Jovi commented 8 years ago

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.

Roh19 commented 8 years ago

Hi,

The same issue happens for me too. Please help me out.

jkereako commented 8 years ago

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.