flexboxobjc_deprecated icon indicating copy to clipboard operation
flexboxobjc_deprecated copied to clipboard

Calculating the dimensions of FlexBoxContainer that would FIT all of its subviews, which are laid out with FlexboxKit

Open fatuhoku opened this issue 8 years ago • 0 comments

I want to self-size a CollectionView cell with Flexbox, because I've experienced both memory and performance issues when scrolling with my existing implementation, which uses Auto-layout declared in IB. There's about 10 constraints per item, and 12 items are displayed at any one time.

Let's say we're laying out a something like this Pinterest card here:

screen shot 2015-12-21 at 13 42 14

It's clear that the content dictates the height of the card: the card's width may be fixed, but its height is the sum of the height of the image and the height of each info section beneath it; which in turn, are determined by the height of the labels inside of each section.

Let's say we know the aspect ratio of the image, and the height of the text.

Rather than using Flexbox to 'lay out the subviews' , we actually want FlexBox to figure out just how tall our FlexBoxContainer needs to be!

This information can be used in, e.g. UICollectionViewCell's preferredLayoutAttributesFittingAttributes method.

Is this possible?

fatuhoku avatar Dec 21 '15 11:12 fatuhoku