Iglistkit: Layouts with automatic cell sizing crash when the side insets are non-zero

Created on 23 Jan 2017  路  3Comments  路  Source: Instagram/IGListKit

New issue checklist

General information

  • IGListKit version: 2.1.0
  • iOS version(s): 10.2
  • CocoaPods/Carthage version: DNA
  • Xcode version: 8.2.1
  • Devices/Simulators affected: All test cases affected (7 Simulator/6s Plus)
  • Reproducible in the demo project? (Yes/No): Yes
  • Related issues: None

Self-sizing cell layouts, as shown in the SelfSizingCellsViewController example, break when the inset.right or inset.left values for the section controller are non-zero.

The following console output is shown when inset.left is set to 10, instead of the current value of 0, in the example SelfSizingSectionController.

2017-01-23 21:00:30.619 IGListKitExamples[17836:3387117] The behavior of the UICollectionViewFlowLayout is not defined because:
2017-01-23 21:00:30.619 IGListKitExamples[17836:3387117] the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values.
2017-01-23 21:00:30.619 IGListKitExamples[17836:3387117] Please check the values returned by the delegate.
2017-01-23 21:00:30.620 IGListKitExamples[17836:3387117] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x7ff28ec159a0>, and it is attached to <IGListCollectionView: 0x7ff28f030200; baseClass = UICollectionView; frame = (0 0; 414 736); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x60000005d220>; layer = <CALayer: 0x600000035920>; contentOffset: {0, -64}; contentSize: {0, 0}> collection view layout: <UICollectionViewFlowLayout: 0x7ff28ec159a0>.
2017-01-23 21:00:30.620 IGListKitExamples[17836:3387117] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

[This set of messages is shown a whole bunch of times, presumably for each separate self-sizing view in the controller.]

question

Most helpful comment

@zhubofei This solved it, thanks!

All 3 comments

@HarshilShah This seems to be a flow layout problem. After setting insets to 10, the width of the section is containerWidth + 10 + 10, which is larger than the width of the collectionView. This is not allowed in UICollectionViewFlowLayout.

@HarshilShah Set

 func sizeForItem(at index: Int) -> CGSize {
        return CGSize(width: collectionContext!.containerSize.width - 20, height: 55)
 }

in SelfSizingSectionController should solve your issue.

20 = inset.left + inset.right

@zhubofei This solved it, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drinkius picture drinkius  路  3Comments

jessesquires picture jessesquires  路  3Comments

kanumuri9593 picture kanumuri9593  路  3Comments

shuhrat10 picture shuhrat10  路  3Comments

alexwillrock picture alexwillrock  路  3Comments