-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple Section Header Overlapping Cells #13
Comments
I have the same problem, how to solve it? |
Here's my current workaround which I think is not a perfect solution: add the following extension and custom class to your project:
Then, in your viewController where you are implementing the AlignedCollectionViewFlowLayout, override the viewDidAppear function as follows:
You'll also need to edit the AlignedCollectionViewFlowLayout.swift file. You need to edit the private setFrame function as follows:
if setFrame wasn't private, we could've overridden it in the extension and never had to worry about updating this in the future if the original author update this library. I hope this help you. |
I am having a hard time trying to add header sections along with your awesome AlignedcollectionViewFlowLayout, but my attempts are failing.
What I did so far was adding layoutAttributesForSupplementaryView:ofKind:at to your .swift file and modifying your setFrame function to process UICollectionElementKindSectionHeader. I also added a public var for header's height: headerHeight
and
My implementation seems to work right, but when I segue to my ViewController where I am implementing your custom flow layout, viewForSupplementaryElementOfKind is called too soon before the correct attributes are calculated. I know this because I am triggering a call to viewForSupplementaryElementOfKind by reloadItems(at:) inside collectionView:didSelectItemAt
(Edit: I added the following block to my viewDidAppear to work around this delay
)
I've also printed frame values for first cell in section as well as the header frame. It seems that my attributes are calculated 4 times and the viewForSupplementaryElementOfKind function takes values from the 3rd call
Edit:
see attachment for screens after segueing to VC, log from console about first cell in section and header saved frame, and screen of collectionView after triggering didSelectItemAt or reloadingItems in viewDidAppear
I'd really appreciate it if you'd help me to avoid making extra call to reloadItems(at:)
The text was updated successfully, but these errors were encountered: