Forum Xamarin.iOS

NSCollectionView footers

IvanIcinIvanIcin USMember ✭✭✭
edited July 2018 in Xamarin.iOS

I guess that at least part of this is a bug, but let me check if there is some way to properly implement footers for NSCollectionView.

Currently Xamarin doesn't support collectionView:viewForSupplementaryElementOfKind:atIndexPath:, so this is what I did:

    public NSView GetViewForSupllementaryElement(NSCollectionView collectionView, NSString kind, NSIndexPath indexPath)
        var view = collectionView.MakeSupplementaryView(kind, "FooterView", indexPath);
        return view;

I have also registered this view like:

cardsCollectionView.RegisterClassForSupplementaryView(typeof(ViewHelpers.FooterView), (NSString)"NSCollectionElementKindSectionFooter", 

Unfortunately, there seems to be some problem in GetViewForSupllementaryElement - the 'kind' I get there is "UICollectionElementKindSectionFooter" which shouldn't exist on macOS. So I tried to play with those two strings (sending hard coded value in MakeSupplementaryView instead of 'kind' and no combination works:
1. if I use "UICollectionElementKindSectionFooter" on both places no footer is visible
2. if I use "NSCollectionElementKindSectionFooter" (which should be the correct way) on both places, the app crashes
3. if I use "UICollectionElementKindSectionFooter" in MakeSupplementaryView and "NSCollectionElementKindSectionFooter" in registration the footer finally appears, but it is buggy and causes the first item to be remembered and smeared over content that later gets there.

Any suggestions or should I file the bug? Or can I even file the bug as collectionView:viewForSupplementaryElementOfKind:atIndexPath: is not implemented yet?


Sign In or Register to comment.