title: How to have an app centered on and/or fill the screen?
body: <p>I am new to Xcode and I have a very simple layout with a square ImageView with two buttons below it. I wrap these in a UIView called Box (as a subview target for <code>viewForZoomingInScrollView</code>), which is wrapped in a ScrollView.</p>
  
  <p>I tried building it in two different ways with the SingleView template. In the first way I changed the ViewController's view to a ScrollView, like this.</p>
  
  <p><a href="https://i.stack.imgur.com/quyFb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/quyFb.png" alt="enter image description here"></a></p>
  
  <p>Second, I also tried it with the Scrollview inside the ViewController's view like this.</p>
  
  <p><a href="https://i.stack.imgur.com/7rDRq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7rDRq.png" alt="enter image description here"></a></p>
  
  <p>Everything works fine or as expected, in both cases, except: In both cases, the entire ViewController, stays pinned to the top left corner of the screen, regardless of orientation or zoom level. </p>
  
  <p><strong>* Omg, I solved all my resource management and action issues in one day and now I have spent nearly a week fighting with Layout *</strong></p>
  
  <p>When I have no constraints, like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Oy29u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Oy29u.png" alt="enter image description here"></a></p>
  
  <p>The App opens like this. View is Black, ScrollView is purple, Box is DKGray, and ImageView is LTGray</p>
  
  <p><a href="https://i.stack.imgur.com/8u6yi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8u6yi.png" alt="View is Black, ScrollView is Purple, Box is DKGray, and ImageView is LTGray"></a></p>
  
  <p>When I pinch it, the image stays (after bouncing) pinned to the top left.</p>
  
  <p><a href="https://i.stack.imgur.com/Zjdeh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zjdeh.png" alt="enter image description here"></a></p>
  
  <p>If I add centering constraints to ScrollView and Box, </p>
  
  <p><a href="https://i.stack.imgur.com/siLSZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/siLSZ.png" alt="enter image description here"></a></p>
  
  <p>ScrollView's constraints are respected but Box's are not. (Actually when the app opens Box fills ScrollView, it is only after pinching that Box goes up into the top left. Can scrolling destroy the constraints...? Do I have to put constraints in <code>scrollViewDidEndZooming</code>?)</p>
  
  <p><a href="https://i.stack.imgur.com/nmVb1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmVb1.png" alt="enter image description here"></a></p>
  
  <p>Here are my current sub-questions. When Layout doesn't have enough constraints, it must add them. Does the constraints it adds have priority over mine? Is there a way to see what constraints it adds? I get these warnings with the constraints above.</p>
  
  <p><a href="https://i.stack.imgur.com/oKq8J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oKq8J.png" alt="enter image description here"></a></p>
  
  <p>Over Arching Question: <strong>How do I get it to be in the center of the iOS screen, or to fill the screen?</strong> I imagine there is an Interface Builder solution and a code solution, either or both would be of interest.</p>
  
  <p>Thanks for reading.</p>