title: How to display 3 cells per row in UICollectionView?
body: <p>I used a custom flow layout according to <a href="http://dativestudios.com/blog/2015/01/08/collection_view_layouts_on_wide_phones/" rel="noreferrer">this post</a>.
  Here is my implementation:</p>
  
  <pre><code>@implementation CustomLayout
  -(void)prepareLayout{
  [super prepareLayout];
  //    [self invalidateLayout];
  if(self.collectionView){
      CGSize newItemSize=self.itemSize;
  
  // Number of items per row
      int itemsPerRow=3;
  
      float totalSpacing=self.minimumLineSpacing*(itemsPerRow-1);
  
      newItemSize.width=(self.collectionView.bounds.size.width -totalSpacing)/itemsPerRow;
  
      if(self.itemSize.height&gt;0){
          float itemAspectRatio=self.itemSize.width/self.itemSize.height;
          newItemSize.height=newItemSize.width/itemAspectRatio;
      }
  
      [self setItemSize:newItemSize];
  
  }
  
  
  }
  @end
  </code></pre>
  
  <p>This is what I've got: <a href="https://i.stack.imgur.com/DsbXN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DsbXN.png" alt="Result"></a>
  What did I miss? I've come across some other SO posts but no luck so far.</p>