Closed MathieuWhite closed 7 years ago
@MathieuWhite thanks for the report! So from the debug dump, I can see that
UICollectionViewFlowLayout
FooterView
Is that right?
Could you provide a zip of the example project setup that can repro the crash? That way I can look into it a little deeper. I'm unclear if this is an issue w/ IGListKit or some UIKit bug w/ UICollectionViewFlowLayout
.
@rnystrom Yes, that is exactly the layout and supplementary view used.
Here is a zip of the example project setup used. You can launch the iOS Example. To reproduce this issue, type the letter 'T' in the search bar.
@MathieuWhite your bug is in dynamically changing if a supplementary view exists or not in supportedElementKinds
. UICollectionViewFlowLayout
isn't meant to dynamically insert/remove supplementary views w/out calling invalidateLayout
. A SO question that is exactly the same issue:
One solution is to move the isLastSection
check to the size and use a non-zero size.
func sizeForSupplementaryView(ofKind elementKind: String, at index: Int) -> CGSize {
guard let width = collectionContext?.containerSize.width else {
fatalError()
}
return CGSize(width: width, height: isLastSection ? 40.0 : 0.01)
}
I verified that this works. A little bit of a hack, but since this is a limitation of UICollectionViewFlowLayout
I'm going to go ahead and close this.
Thanks for the quick turnaround, @rnystrom! Much appreciated.
Hey guys,
I just came across a crash while trying to work with supplementary views in a section controller using the
IGListSupplementaryViewSource
protocol. Nothing fancy going on with the collection view layout, just using the defaultUICollectionViewFlowLayout
on the collection view. See the assertion failure below:To provide some context, the collection view is displaying a list of items using an
ItemSectionController
. This is the only section controller type being returned to the list adapter. There is a search field in the navigation bar, and text input is used to filter the results and sort by relevance. The section controller conforms toIGListSupplementaryViewSource
, and returns a supplementary view of kindUICollectionElementKindSectionFooter
ifself.isLastSection
isYES
.So this means you would see a list of results, and below the last cell a supplementary view is displayed with a label saying there are no more results. Note: Before switching over to using a supplementary view for this, it was set up to be its own section controller.
I thought I would checkout the
IGListKitExamples
to verify if I could reproduce the same issue. The perfect demo to test is theSearch Autocomplete
example provided. It's very similar to our app. I setup a new supplementary view for a footer, and madeLabelSectionController
conform toListSupplementaryViewSource
. At this point the crash is not reproducible, so I continued to investigate. I noticed theSearchViewController
always returns aSearchSectionController
which contains the search bar. So I got rid of theSearchSectionController
and used aUISearchBar
in the navigation bar. Now, the issue is reproducible.So it seems that if the section controller that contains a supplementary view is moving to the first index path, it crashes. In the example app, the
SearchSectionController
is always the first index path so this doesn't crash. In fact, I checked this theory against our app and if I returned a different section controller as the first index path, it does not crash.New issue checklist
README
and documentationGeneral information
IGListKit
version: 3.1.0Debug information