Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's because you cannot just change the frame of an object that has autolayout constraints (because constraints dictate the locations, not manually set <code>frame</code> properties ... the <code>frame</code> properties will be reset as constraints are reapplied). See <a href="https://stackoverflow.com/questions/14189362/animating-an-image-view-to-slide-upwards/14190042#14190042">this</a> loosely related post in which it is demonstrated how to properly adjust a constraint to move a view. (In that case, we're animating, which is not the issue here, but it does demonstrate how how one adjusts a constraint to effect the movement of a <code>UIView</code>.)</p> <p>In short, if you want to move a <code>UIView</code> within autolayout, you must not try to change the <code>frame</code>, but rather adjust the constraints themselves. This is simplified if you create <code>IBOutlet</code> references for the constraints themselves, at which point, you can adjust the <code>constant</code> of the <code>NSLayoutConstraint</code>.</p> <hr> <p><strong>Update:</strong></p> <p>Egor recommended enumerating the constraints and editing the one that matched the one in question. That works great, but personally, I prefer to have an <code>IBOutlet</code> for the specific constraint I want to edit rather than enumerating them and hunting the one in question. If you had an <code>IBOutlet</code> called <code>indentViewWidthConstraint</code> for the width <code>NSLayoutConstraint</code> of the <code>indentView</code>, you could then simply:</p> <pre><code>self.indentViewWidthConstraint.constant = newIndentConstantValue; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload