pitiphong-p / CollectionViewShelfLayout

A UICollectionViewLayout subclass displays its items as rows of items similar to the App Store Feature tab without a nested UITableView/UICollectionView hack.
MIT License
376 stars 30 forks source link

Fix layout and scrolling issues when going to landscape interface orientation #4

Closed damienrambout closed 7 years ago

damienrambout commented 7 years ago

I've noticed 2 bugs when using this layout in landscape orientation :

  1. The section header/footer bounds are not updated (i.e. they keep their original frame)
    • This has been fixed by overriding shouldInvalidateLayout.
  2. The panning scrollviews are broken (you must scroll up/down to actually scroll left/right)
    • This has been fixed by adding/removing scrollviews to the collection view. The scrollviews are hidden (alpha = 0). This makes sure scrollviews work in any interface orientation.
pitiphong-p commented 7 years ago

Thank you for this PR. I have some opinion on this.

  1. The behavior that section headers/footers are not pinned to top is an intended behavior. If you want to include this feature into CollectionViewShelfLayout, I suggest you to add this as an opt-in feature with a mutable property
  2. I believe this is a UIKit bug. I've investigated this for a moment and will update to you again later
damienrambout commented 7 years ago
  1. Headers and footers are not pinned. Their width is now updated when the bounds of collection view are updated. Otherwise, they were keeping their original width (i.e. Porta it's width)
  2. I don't think this is a bug in UIKit. Views are meant to be added to a view hierarchy at some point. I believe UIScrollView can adapt its scrolling behavior thanks to its ancestor window.
pitiphong-p commented 7 years ago

I did some recall by watching this session again. I'm still a little bit confused but I can agree with you now that those UIScrollView need to be added to the view hierarchy. By the way I still need you to change your code to match my convention and style.