title: UICollectionView, simply fit cell to width?
body: <p>Here's a simple UICollectionView in yellow</p>
  
  <p><img src="https://i.stack.imgur.com/mexFJ.png" alt="enter image description here"></p>
  
  <p>The red arrow sets the width of the cell. (TBC: clicking on the pink cell: for 'size' select 'Default', then what you set at the red arrow becomes the size of the cell.)</p>
  
  <p>Example, for an upright iPhone set width to 320.</p>
  
  <p>But this seems crazy ... surely I can set the cell width <strong>based on the width of the UICollectionView</strong>?</p>
  
  <p>There's no problem autosizing the view itself ..</p>
  
  <p><img src="https://i.stack.imgur.com/XWlpZ.png" alt="enter image description here"></p>
  
  <p>That works fine.</p>
  
  <p>But it seems crazy that I can't set the width of the CELL to be "same as the view". It seems hard to believe one has to set it manually, in code?</p>
  
  <p>TBC In other words, as Nikita points out,</p>
  
  <pre><code>-(CGSize) collectionView:(UICollectionView *)collectionView
       layout:(UICollectionViewLayout *)collectionViewLayout
       sizeForItemAtIndexPath:(NSIndexPath *)indexPath
      {
      return self.view.frame.size;
      }
  </code></pre>
  
  <p>(indeed you also typically need this ...)</p>
  
  <pre><code>-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView
     layout:(UICollectionViewLayout*)collectionViewLayout
     insetForSectionAtIndex:(NSInteger)section
      {
      return UIEdgeInsetsMake(0,0,0,0);   //t,l,b,r
      }
  </code></pre>
  
  <p>In fact - you have to do that in code?!  There's no way to do that in Storyboard, with autolayout, or anything else?!</p>