title: UICollectionView cell ignores UICollectionViewDelegateFlowLayout - sizeForItemAt
body: <p>I am trying to layout the size of my collectionViewCell so that in each row there are 7 cells (easy right?). </p>
  
  <p>The cell is very simple, it only has a UILabel with top, left, bottom and right constraints of 0.</p>
  
  <p>I have setup the sizeForItemAt method as below, made sure my controller is a collectionViewDelegateFlowLayout, collectionViewDelegate and collectionViewDataSource, and that collectionview.delegate and .datasource = self.</p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
          let safeScreenWidth = self.view.frame.size.width - 30
  
          let width: CGFloat = (safeScreenWidth / 7)
          let height: CGFloat = 40.0
  
          return CGSize(width: width, height: height)
      }
  </code></pre>
  
  <p>The method is called correctly (checked with break points and print()) however the cell decides to totally ignore the size given and comes out with a size just enough to contain its label's text (if the label's text is empty the app crashes for "Invalid parameter not satisfying: !CGSizeEqualToSize(size, CGSizeZero)").</p>
  
  <p>I tried setting different sizes such width = 200, height = 200; but nothing changes the cell is always very small, as I said, just enough to fit its label's text.</p>
  
  <p>A quick solve is setting height and width constraints for the label in cellForItemAt, but I want to understand why sizeForItemAt does not work.</p>