title: IOS 11: UICollectionView on iPhone X is sized wrong
body: <p>I have a collection view that the frame appears too tall on the iPhone X. On every other device, the sizing and scrolling works properly as shown below:</p>
  
  <p><a href="https://i.stack.imgur.com/OQJk8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OQJk8.png" alt="enter image description here"></a></p>
  
  <p>However on iPhone X, it looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Mtf3V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mtf3V.png" alt="enter image description here"></a></p>
  
  <p>The top row is cut off, and it does not scroll all the way down to the last row. Somehow, the sizing correctly calculates the width but not the height, which is about 70 pixels too tall. (I'm not worried about the top and bottom bars. I'll fix those later)</p>
  
  <p>I'm guessing this has something to do with the inset adjustments for the iPhone X screen, but I can't figure out how to fix it. I've tried this in where I size the collection view: </p>
  
  <pre><code>if #available(iOS 11.0, *) {
      collectionView.contentInsetAdjustmentBehavior = .always
  }
  </code></pre>
  
  <p>However, I can't seem to fix it.</p>
  
  <p>Edit:</p>
  
  <p>To clarify, the set up for this menu is as follows, there are actually two collection views onscreen. The first scrolls horizontally with paging enabled so that it locks onto each cell. The other collection views are the cells for the first one, and they scroll vertically. We'll call these subCollectionViews.</p>
  
  <p>The subCollectionViews are receiving a size from the original collection view thats too tall. On the storyboard, the collection view's height is defined with respect to the top bar and the bottom paging bar as flush. In the story board, the height of the collection view is about 70 pixels larger than the calculated height during runtime.</p>
  
  <p>So for the cell's layout guide:</p>
  
  <pre><code>override func awakeFromNib() {
      cellImage = UIImageView(frame: contentView.frame)
      cellImage?.contentMode = .scaleAspectFill
      cellImage?.clipsToBounds = true
  
      contentView.addSubview(cellImage!)
  }
  </code></pre>
  
  <p>and for the collection view's layout: </p>
  
  <pre><code>        layout.scrollDirection = .vertical
          layout.minimumLineSpacing = 8
          layout.minimumInteritemSpacing = 8
  </code></pre>
  
  <p>for the storyboard presets:</p>
  
  <p><a href="https://i.stack.imgur.com/GO69k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GO69k.png" alt="enter image description here"></a></p>
  
  <p>I think this is what y'all asked for. If there's anything you need to see, just ask.</p>