Iglistkit: How to "fill" remaining space with section controller?

Created on 15 Mar 2017  路  5Comments  路  Source: Instagram/IGListKit

Unique internal problem that I figured I'd open and see if others have ideas. h/t @dshahidehpour for bringing this up.

Say we have a list with a couple items at the top and we want to "fill" the bottom space up with a single section controller that displays some content, centered in the remaining space. (e.g. imagine an empty-state message going here).

drawing

Here's why this is tricky:

  • [self.collectionContext containerSize] returns the inset bounds of the collection view
  • When the section controller is asked sizeForItemAtIndex:, the layout hasn't been setup
  • Section controllers are designed to be agnostic of each other, there's no way to "reach" over to neighbor section controllers to find their size/position

Anyone have any thoughts on how to accomplish this? Open to adding an API to IGListCollectionContext if necessary.

question

Most helpful comment

@weyert good call, I'm going to close this. We _did_ find a way to do this in Instagram, but its not the most elegant. Very "chicken or the egg" type of problem.

All 5 comments

@rnystrom Can we subclass the IGListCollectionViewLayout and modify the layout attributes for the last SC?

@zhubofei interesting! We did remove the subclass restriction, so this is totally possible. I hadn't even thought of that.

Did this ever get solved?

@weyert good call, I'm going to close this. We _did_ find a way to do this in Instagram, but its not the most elegant. Very "chicken or the egg" type of problem.

@weyert good call, I'm going to close this. We _did_ find a way to do this in Instagram, but its not the most elegant. Very "chicken or the egg" type of problem.

@rnystrom Can you share any info on how you did it?

Was this page helpful?
0 / 5 - 0 ratings