I notice that you have a priority of 500, which means that you're willing to break this constraint in order to satisfy other constraints. I wonder what other constraints you have in place. If doing this in Interface Builder, it has an annoying tendency (in Xcode 4.6.x at least) to add whatever constraints it thinks it needs in order to eliminate ambiguity. You might want to check that you don't have other height constraints, or top and bottom constraints that are taking precedence.
Bottom line, your technique for setting the constant
is fine (thought, I find just using setNeedsLayout
is sufficient) and the problem probably rests with other constraints that might be lingering about.
If you change the priority of this constraint to 1000, if you have conflicting constraints you'll get an error as to what they are, which is helpful in diagnosing the problem. But as it is, you're telling autolayout that it's ok if this height constraint is ignored in favor of other conflicting constraints (of greater or equal priority). By setting the priority to 1000, you're saying that you never want this constraint to be ignored.