title: After setting a UIView Height Constraint to 0, UIButton clicks do not register
body: <p>I am using iOS Autolayout. I have a UIView which I would like to hide sometimes based on some criteria within the application. Because everything is contained within a long UIScrollView, to 'hide'/remove this element, I am simply setting the UIView's height constraint to 0 which should shift up all of the elements below it. </p>
  
  <pre><code>viewHeightConstraint.constant = 0
  viewHeightConstraint.layoutIfNeeded()
  </code></pre>
  
  <p>The <code>viewHeightConstraint</code> variable refers to a NSLayoutConstraint that I Ctrl+Dragged to get an outlet in my code from the storyboard. </p>
  
  <p><a href="https://i.stack.imgur.com/atnXM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/atnXM.png" alt="enter image description here"></a></p>
  
  <p>The UIView I am talking about is the gray box in the image above. After setting this UIView's height to 0, and updating the view, it does disappear and everything shifts upward as it should. </p>
  
  <p>However, the two blue UIButtons which originally functioned, do not register any clicks after this Autolayout change. I am setting <code>self.view.translatesAutoresizingMaskIntoConstraints = true</code> in <code>viewDidLoad()</code> which did not fix it.</p>
  
  <p>EDIT: The problem was in my view hierarchy.</p>