What is a 'UIView-Encapsulated-Layout-Width' constraint?
A quick and nice fix, is to assign 999
priority value to the custom constraints with high priority. The encapsulated & auto-generated constraints should dominate with higher priority than your constraints.
i played with the sample, i think these codes is causing the Autolayout exception.
CGFloat height = MAX(0, -y + maxY);
line 79 in CSStickyHeaderFlowLayout.m.
if you use a static value for the height like 200, the exception won't happen anymore. i can't understand what exactly is UIView-Encapsulated-Layout, but seems like dynamically changing the UICollectionViewLayoutAttributes frame may cause that problem. in the sample project, it's the height, in PO's problem, i guess it's the width. Maybe i can dig a little bit more into it, if you think that would be helpful
My situation
For me, I knew (logically) that my programmatic constraints should have worked. I was updating them after rotation of the device.
My quick-and-easy solution without changing constraints was to make sure that this was all done on the main thread. Why? I'm not too sure, but I assume that the rotation update must be in an asynchronous thread.
How I fixed it
From:
topTitleLeadingAnchorLandscape.isActive = true
To:
DispatchQueue.main.async { self.topTitleLeadingAnchorLandscape.isActive = true}
Hope this saves someone lots of time in the future! 😀