The layoutsubviews is called in the following cases:
1. Init initialization does not trigger Layoutsubviews
when initialized with initWithFrame, however, when the value of rect is not Cgrectzero, it also fires
2, Addsubview will trigger Layoutsubviews
3, set the view frame will trigger the layoutsubviews, of course, if the frame value has changed before and after the setting
4, rolling a uiscrollview will trigger layoutsubviews
5. Rotate screen will trigger the Layoutsubviews event on the parent UIView
6, change the size of a uiview will also trigger the parent UIView on the Layoutsubviews event
But here are the notes: 1. If the button or ScrollView is initialized in the initWithFrame method (Note: This can be changed in a variety of states: for example, the button is clicked and not clicked, ScrollView is scrolling and does not scroll)
This time layoutsubviews will be called multiple times. (proved by Test)
Recommendation: Do not write the initialization view code in the Layoutsubviews method to allow only the layout to be changed inside
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
[IOS] calls the Layoutsubviews method (sometimes it's called 2 times)