I have a view controller and I want to craete and set my view constraints in updateViewConstraints. I have a break point in that method and it's never getting called.
Why might it not be getting called? When will the framework want to call this method on my view controller?
updateViewConstraints
is called by viewWillLayoutSubviews
(via your view's layoutSubviews
method along the way). As the name suggests, this is called whenever your view controller needs to update its layout.
If you finding that updateViewConstraints
is never being called then you should make sure that you are calling super
your view controller's methods where required.
Also, it sounds as if you are creating your constraints inside updateViewConstraints
? That may also be the cause of your problem. You should be updating your constraints in that method, not creating them (in the same way that in layoutSubviews
you position your views, but don't instantiate them).
You are in ViewController and you want the system to call updateViewConstraints
, then you have to call this
[self.view setNeedsUpdateConstraints];
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