I am using autolayout for parts of my UI. When I check the width of my view in viewWillAppear, the width has not yet updated. It gets updated after the second callback to - (void)updateViewConstraints. The issue is I set up my parts of my UI (using spring and struts for legacy reasons) based on this width in viewWillAppear. When is the good time to set up this legacy UI which takes in a width parameter ?
thanks
Layout happens after viewWillAppear
returns. Do it in viewDidLayoutSubviews
(in your view controller) or in layoutSubviews
(in your custom view subclass). Either way, be sure to call super
first.
Another way is to force layout by sending [view layoutIfNeeded]
. Then you can add subviews and set their springs and struts. The system will perform layout again (at its usual time) because you added subviews.
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