Skip to content

[Example apps] Adding custom calculated cell heights to the CustomCollectionView example. #116

Open
@garrettmoon

Description

@garrettmoon

From @marcelofabri on December 18, 2015 19:37

Hi,

This is my first time playing with AsyncDisplayKit, so sorry if this is a stupid question.

I'm trying to modify the CustomCollectionView to support calculated cell heights, as the current version asks a MosaicCollectionViewLayoutDelegate the original cell size and I'd like to avoid it.

I was able to change _itemSizeAtIndexPath in MosaicCollectionViewLayout to this:

- (CGSize)_itemSizeAtIndexPath:(NSIndexPath *)indexPath
{
  ASCollectionView *collectionView = self.collectionView;
  CGSize calculatedSize = [collectionView calculatedSizeForNodeAtIndexPath:indexPath];
  CGSize size = CGSizeMake([self _columnWidthForSection:indexPath.section], calculatedSize.height);
  return size;
}

However, this causes a crash unless I change the ASCollectionView to have asyncDataFetching set to NO.

Is this the "right way"? How would you do this?

Thanks!

Copied from original issue: facebookarchive/AsyncDisplayKit#954

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions