title: iOS two views cover exactly half of parent view
body: <p>In my app I want to achieve this layout:</p>
  
  <p><img src="https://i.stack.imgur.com/6qMp1.png" alt="enter image description here"></p>
  
  <p>So parent view contains two sub views. First one ends exactly in a middle (height / 2) and second starts in a middle of parent view. I have found out that it is impossible to do that in the IB with constraints. So I used this code in <code>viewDidLoad</code> method:</p>
  
  <pre><code>NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:firstView
                                                                attribute:NSLayoutAttributeHeight
                                                                relatedBy:0
                                                                   toItem:self.view
                                                                attribute:NSLayoutAttributeHeight
                                                               multiplier:0.5
                                                                 constant:0];
  
  [self.view addConstraint:constraint];
  </code></pre>
  
  <p>Now it works but only if the app runs on the iPhone. Because size of the view is like iPhone screen. If this app runs on the iPad, there is a problem because screen has different size so this parent view is longer. And constraint (code above) still takes 0.5 * size of the views size from the IB and not size from the iPad size of the view. Item <code>toItem:self.view</code> still takes size from the IB.</p>
  
  <p>Result is that this view has a same size in the iPad as in the iPhone. In the iPad there is a large blank space and then there is a view with iPhone size.</p>
  
  <p>Can you tell what I have to do to make it universal for various screen sizes? Thank you very much </p>