In my viewController.view
, I have some work done in viewWillLayoutSubviews
that organizes which subviews are visible, which to bring to the front, which to hide, etc, if the orientation changes.
But I have buttons on my view that somehow cause viewWillLayoutSubviews
to get called every time they are pressed. Why would this be? According to the Apple docs, viewWillLayoutSubviews
is only called if your view's bounds change.
The result is that my views are getting re-arranged just from pressing a button, but I'm not rotating the device at all nor am I manipulating view.bounds or view.frame in any way.
Meaning the method viewDidLayoutSubviews is called every time the view size changes and the view layout has been recalculated.
The viewWillLayoutSubviews() method is also called after the view is resized and positioned by its parent. If a view controller is not visible when an orientation change occurs, then the rotation methods are never called. However, the viewWillLayoutSubviews() method is called when the view becomes visible.
viewDidLayoutSubviews()Called to notify the view controller that its view has just laid out its subviews.
You better do one thing andrews take a bool and set it TRUE on button press and check it on layoutSubviews and operate whether it is true or false. You get it what i am trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With