Iglistkit: Is it possible to use variable height cells with IGListSingleSectionController?

Created on 24 Mar 2017  路  2Comments  路  Source: Instagram/IGListKit

New issue checklist

General information

  • IGListKit version: Last one.
  • iOS version(s): iOS 9 and iOS 10
  • CocoaPods/Carthage version: Last one
  • Xcode version: 8.2.1
  • Devices/Simulators affected:
  • Reproducible in the demo project? (Yes/No): Yes
  • Related issues: None

Hello,

Is it possible to use variable height cells with IGListSingleSectionController? Basically I want to use constraints and estimatedSize.

It seems we have to pass a block with the size.

https://instagram.github.io/IGListKit/Classes/IGListSingleSectionController.html#/c:objc(cs)IGListSingleSectionController(im)initWithCellClass:configureBlock:sizeBlock:

But docs don't say more info. Or the sample app.

Thanks a lot.

question

All 2 comments

The sample app shows how to pass the block:

let sizeBlock = { (item: Any, context: IGListCollectionContext?) -> CGSize in
            guard let context = context else { return .zero }
            return CGSize(width: context.containerSize.width, height: 44)
        }

I do not think there is anything here stopping you from calculating the height on a per cell basis? 馃 :)

Thanks @Ricardo1980 !

The size block is only if you want to use the provided IGListSingleSectionController.

Otherwise, in your own custom SectionController, you can provide cell sizes based on index (just like collection view).

https://instagram.github.io/IGListKit/Protocols/IGListSectionType.html#/c:objc(pl)IGListSectionType(im)sizeForItemAtIndex:

Was this page helpful?
0 / 5 - 0 ratings