title: Display just two columns, with multiple rows in a CollectionView using storyboard
body: <p>I want to display only two cells in a row, no matter what the iPhone screen size is. Like,
  <a href="https://i.stack.imgur.com/ZwtHK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZwtHK.png" alt="End result required"></a></p>
  
  <p>My storyboard contains a <code>UICollectionView</code>,connected by constraints.</p>
  
  <p><a href="https://i.stack.imgur.com/rNDIA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rNDIA.png" alt="Storyboard preview"></a></p>
  
  <p>The storyboard settings for the <code>UICollectionView</code> is,
  <a href="https://i.stack.imgur.com/3eQib.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3eQib.png" alt="enter image description here"></a></p>
  
  <p>Now, when I run this in 6, 5s or below, only one cell appears in a row. The code I'd used is,</p>
  
  <pre><code>- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
      return [categoryImages count];
  }
  - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
      homePageCells *cell = (homePageCells *)[collectionView dequeueReusableCellWithReuseIdentifier:@"cells" forIndexPath:indexPath];
      cell.categoryName.text = [categoryNames objectAtIndex:indexPath.row];
  
      return cell;
  }
  </code></pre>
  
  <p>I tried detecting the screen size and assigning appropriate cell size programmatically using the code,</p>
  
  <pre><code>- (CGSize)collectionView:(UICollectionView *)collectionView
  layout:(UICollectionViewLayout *)collectionViewLayout
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      CGSize sizes;
  
  
      CGSize result = [[UIScreen mainScreen] bounds].size;
      NSLog(@"%f",result.height);
      if(result.height == 480)
      {
          //Load 3.5 inch xib
          sizes =CGSizeMake(170.f, 170.f);
          NSLog(@"3gs");
      }
      else if(result.height == 568)
      {
          //Load 4 inch xib
          sizes =CGSizeMake(130.f, 130.f);
          NSLog(@"5s");
  
      }
      else if(result.height == 667.000000)
      {
          //Load 4.7 inch xib
          sizes =CGSizeMake(160.f, 160.f);
          NSLog(@"6");
  
      }
      else
      {
          NSLog(@"else");
  
          sizes =CGSizeMake(170.f, 165.f);
  
      }
      return sizes;
  }
  </code></pre>
  
  <p>But I also know that this isn't the right way, so please give me a right way to handle this.</p>