Instagram / IGListKit

A data-driven UICollectionView framework for building fast and flexible lists.
https://instagram.github.io/IGListKit/
MIT License
12.87k stars 1.54k forks source link

IGListDisplayDelegate methods are not called when section controller displays only supplementary views without cells. #300

Closed almas73 closed 7 years ago

almas73 commented 7 years ago

New issue checklist

General information

With the current implementation non of the display delegates are called when number of items is equal to 0. It makes sense that these two methods are not called:

- (void)listAdapter:(IGListAdapter *)listAdapter willDisplaySectionController:(IGListSectionController <IGListSectionType> *)sectionController
               cell:(UICollectionViewCell *)cell
            atIndex:(NSInteger)index;
- (void)listAdapter:(IGListAdapter *)listAdapter didEndDisplayingSectionController:(IGListSectionController <IGListSectionType> *)sectionController
               cell:(UICollectionViewCell *)cell
            atIndex:(NSInteger)index;

but I think the other two must be called since the section is displayed and has content (supplementary views):

- (void)listAdapter:(IGListAdapter *)listAdapter willDisplaySectionController:(IGListSectionController <IGListSectionType> *)sectionController;
- (void)listAdapter:(IGListAdapter *)listAdapter didEndDisplayingSectionController:(IGListSectionController <IGListSectionType> *)sectionController;
rnystrom commented 7 years ago

Very interesting. This could actually improve display event notifications sent when a supplementary view is about to appear but the cells haven't yet.

Since we support iOS 8+ this should be easy. We can tap into:

- (void)collectionView:(UICollectionView *)collectionView 
  willDisplaySupplementaryView:(UICollectionReusableView *)view 
  forElementKind:(NSString *)elementKind 
  atIndexPath:(NSIndexPath *)indexPath;

- (void)collectionView:(UICollectionView *)collectionView 
  didEndDisplayingSupplementaryView:(UICollectionReusableView *)view 
  forElementOfKind:(NSString *)elementKind
  atIndexPath:(NSIndexPath *)indexPath;

To give us display start/end events and use the display handler. Great find @almas73!