Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

[ASCollectionNode/ASTableNode] Remeasure cells on trait collection change #1920

Closed
wants to merge 1 commit into from

Conversation

rcancro
Copy link
Contributor

@rcancro rcancro commented Jul 14, 2016

It isn’t enough to call setNeedsLayout on a cell since the container size will change on a trait collection change. We must call measure with the new container size as the constrainted size.

This is all happening on main, which I don’t like, but since we are reacting to a trait collection change does it make sense for it to happen anywhere else?

…ange

It isn’t enough to call `setNeedsLayout` on a cell since the container size will change on a trait collection change. We must call `measure` with the new container size as the constrainted size.

This is all happening on main, which I don’t like, but since we are reacting to a trait collection change does it make sense for it to happen anywhere else?
@Adlai-Holler
Copy link
Contributor

I'm not super familiar with this code, but is it correct to use the trait collection's container size for each node? Would it be enough instead to call [dataController relayoutAllNodes] just like in -[ASCollectionView layoutSubviews]? In fact, any idea why the size-change-handling code in that method isn't handling this?

@rcancro
Copy link
Contributor Author

rcancro commented Jul 14, 2016

As I understand, calling setNeedsLayout or relayoutAllNodes will layout using the cached constrained size. All of the nodes will be asked to layout and say: "Oh, my last layout was for this constrained size. Here use that one." Unless we call measure and pass in the new size, there is no way these nodes get a new constrained size and a new layout for this size.

I agree that using container size for the new constrained size is probably not right. Is there another way I could force a complete re-layout?

@nguyenhuy
Copy link
Contributor

nguyenhuy commented Jul 15, 2016

relayoutAllNodes actually asks for a new constrained size and uses it to measure nodes (here and here). Note that the data source needs to be aware of and return the new size when asked.

@rcancro
Copy link
Contributor Author

rcancro commented Jul 15, 2016

I tried relayoutAllNodes and the cells laid out properly. However, now the layout of the colletion view is wrong. It's like the collection view didn't get the new layout sizes of the cells. If I call measure on the cell then the CV layout is correct.

@rcancro rcancro closed this Jul 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants