Iglistkit: Container size and section insets

Created on 10 Dec 2016  路  7Comments  路  Source: Instagram/IGListKit

It can be a little tricky dealing with insets and collectionContext.containerSize. The container width doesn't account for insets, so if you have the following setup:

  • insets of 10, 10, 10, 10
  • The width of the collection view is 320

If your size method looks like

- (CGSize)sizeForItemAtIndex:(NSInteger)index {
  return CGSizeMake(self.collectionContext.containerSize.width, 50);
}

UICollectionViewFlowLayout will error b/c the item width is 320 but layout adds left/right insets, making the total item width 340.

Maybe we should have a containerInsetSizeForSectionController: method that returns the container size minus insets?

enhancement

Most helpful comment

what about collectionContext.insetContainerSize ?

All 7 comments

what about collectionContext.insetContainerSize ?

@jessesquires only thing we have to add is the section controller b/c each section controller is responsible for their own inset property

Can we verify this is correctly calculated on iOS 9?
Inset were applied incorrectly for me.
I noticed a issue some time ago but I don't have a phone with iOS 9 to reproduce at the moment.

@racer1988 -- this work hasn't been completed. do you want to submit a PR?

@jessesquires If it is not done after the Christmas Holiday, I may try.
I am not a good OBJ-C programmer, I am Swift "onlyish"
but I will have a look if not done in some weeks.

Thanks! :D

@racer1988 Are you still interested in working on this one?

@zhubofei Hi! I did not start, and I might not have the time for a while.
So if you want to take it, go on

Was this page helpful?
0 / 5 - 0 ratings

Related issues

racer1988 picture racer1988  路  16Comments

jessesquires picture jessesquires  路  19Comments

jessesquires picture jessesquires  路  16Comments

Smiller193 picture Smiller193  路  52Comments

heumn picture heumn  路  27Comments