issue
When you use yoga to lay out a slideable interface, you use scrollview. exe. Follow the normal flow layout:
scrollView.contentSize = contentView.frame.size
6. In the controller's viewWillLayoutSubviews method, write the layout of the root view of the yoga layout again, and call applyLayoutPreservingOrigin: method again. The goal is to keep the layout correct when the screen is rotated
The problem: In Step 6, a crash occurs when you call applylayoutpreserving origin: .
The source of the problem
Bugs in the framework
When doing layout calculations, it is not correct to exclude child controls that are not part of the yoga layout. Causes the frame value to be set to {0,0, Nan, Nan } .
Crash reason
When we calculate the layout again in the viewWillLayoutSubviews method, an error occurs when setting their frame value because the horizontal/vertical slider control ScrollIndicator is hidden in the scrollView control and Yoga does not exclude these two controls when calculating the layout.(Why didn't we crash when laying out in viewDidLoad?)Because at that time, the slider control had not yet been created.lazy loading)
Workaround
at
However, this bug has not been updated in time for cocoaPod (the latest version is currently 1.18.1).