Asyncdisplaykit: ASScrollNode change contentSize based on subnode size

Created on 27 Dec 2016  路  7Comments  路  Source: facebookarchive/AsyncDisplayKit

I have a horizontal pagerNode that each of its cells contains an ASScrollNode. and scrollNode contains an inner displayNode which contains all details nodes.
the problem is here scrollNode doesn't adjust its content size based on its container subnode!

screen shot 2016-12-27 at 10 40 34 am

in pagerNode cell:
I have added status displayNode as the only subNode of scrollNode.

override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
let scrollStatusDisplayNodebackgroundSpec = ASBackgroundLayoutSpec(child: statusDisplayNode, background: scrollNode)
        return scrollStatusDisplayNodebackgroundSpec
}

and in container displayNode I have added all its subNodes an it layout well. its size height will change dynamically.

but problem is scrollNode content size won't change! my solution was to adjust content size of scrollNode in layout() method of pagerNode cell.

any idea?

Most helpful comment

The reason for not enabling it by default is that the sizing behavior of ASScrollView will change and will differ between UIScrollView and ASScrollView what is important not differ by default.

All 7 comments

@hashemp206 Hey, can you take a look at just introduced property on ASScrollNode: automaticallyManagesContentSize ... maybe you can leverage this new feature.

@hashemp206 - try setting self.automaticallyManagesContentSize = YES in the ASScrollNode's init method. I think it was included in the latest release, but if not it is on master.

haha @maicki beat me :)

thanks a lot for fast response. unfortunately the version Im using is 3 month old! I need to update it and will inform you.

why automaticallyManagesContentSize by defaults is off?

@hashemp206 - it was a recently added just last week, but at some point it should probably be enabled by default. @garrettmoon

The reason for not enabling it by default is that the sizing behavior of ASScrollView will change and will differ between UIScrollView and ASScrollView what is important not differ by default.

@hashemp206 - I'm going to close this issue since it looks like we resolved it (feel free to re-open it if not).

Was this page helpful?
0 / 5 - 0 ratings