Iglistkit: Show header with empty data

Created on 26 Apr 2018  路  4Comments  路  Source: Instagram/IGListKit

New issue checklist

General information

  • IGListKit version: 3.3.0
  • iOS version(s): 11.3.0
  • CocoaPods/Carthage version:
  • Xcode version: 9.3
  • Devices/Simulators affected:
  • Reproducible in the demo project? (Yes/No):
  • Related issues:

Debug information

# Please include debug logs using the following lldb command:
po [IGListDebugger dump]

I'm trying to implement a screen with a search bar as a header for a collection view but I'm having a hard time trying to make the empty screen appear together with the collection view.

IGListCollectionViewLayout *viewLayout = [[IGListCollectionViewLayout alloc] initWithStickyHeaders:YES topContentInset:0.0f stretchToEdge:NO];
    viewLayout.showHeaderWhenEmpty = YES;
    self.collectionView.collectionViewLayout = viewLayout;

    self.adapter = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:self];
    self.adapter.collectionView = self.collectionView;
    self.adapter.dataSource = self;

Thats how I'm initialising my adapter and collection view. Can anyonehelp please?

missing-info question

Most helpful comment

I see now what I was doing wrong, thank you for the reply

All 4 comments

@brurend I'm not exactly sure what the issue is here. The header just isn't displaying at all? Is there data in your list?

cc @marcuswu0814

There is no data in my list, the empty view is appearing as expected but the sticky header (search bar) is not appearing

Hi @brurend

I'm not sure how did you implement it, but i guess you given an empty data for ListAdapterDataSource method like this:

func objects(for listAdapter: ListAdapter) -> [ListDiffable] {
    return []
}

if so, no section controller be created and IGListKit didn't know your header view. Thus, empty page show but sticky header not.

Sticky header only show if section controller exists and it's method numberOfItems() return 0.
You can take a look this example. I add a red color empty view and you can try it.

Feel free to tell me if having other questions. 馃槄

I see now what I was doing wrong, thank you for the reply

Was this page helpful?
0 / 5 - 0 ratings