Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't change constraint.constant programmatically in viewDidLoad:

I am using autolayout and storyboards. I try to change the constraint in viewDidLoad: so that it takes into account different device models. The constraint is successfully connected as IBOutlet.

In viewDidLoad: I change the constraint like this:

   self.containerConstraint.constant = 250

I DO NOT want to animate the constraint (I later animate it and it works fine). I only want to it to set the view that is constraining to the right spot when the viewController appears. This usually works, however in this case, it persist to use the value determined in storyboard. This is how constraint looks:

enter image description here

What should I do?

like image 255
potato Avatar asked Nov 30 '15 18:11

potato


1 Answers

See that wR hR option under Constant? That was the problem. Looks like constraints that use size classes cant be set in viewDidLoad.

like image 120
potato Avatar answered Sep 21 '22 17:09

potato