title: Collection View Stacking Items in Single Rows – Swift Xcode
body: <p>Would someone please tell me why my collection view is stacking like this instead of side-by-side (until there's no more room and a new row has to be started)? I don't want them stacking with only one per row.</p>
  <p><a href="https://i.stack.imgur.com/TaEP5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TaEP5.jpg" alt="Collection View" /></a></p>
  <pre><code>    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          claimSections.count
      }
      
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
          
          guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: &quot;collectionViewCell&quot;, for: indexPath) as? ClaimTypeCollectionCell else {return UICollectionViewCell()}
          
          cell.claimTypeCollectionImage.image = claimSectionImages[indexPath.row]
          cell.claimTypeCollectionLabel.text = claimSections[indexPath.row]
          cell.frame.size.height = 135
          cell.frame.size.width = 135
          cell.layer.borderWidth = 2
          cell.layer.borderColor = UIColor.black.cgColor
          
          return cell
      }
      
      func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
          if indexPath.row == 0 {
              // The Auto button was tapped -&gt; load the auto page
              modelController.theClaimType = &quot;Auto&quot;
              modelController.isANewFile = true
              performSegue(withIdentifier: &quot;claimTypeToFileSetupSegue&quot;, sender: self)
          } else {
              SCLAlertView().showNotice(&quot;COMING SOON!&quot;, subTitle: &quot;This section is not yet available. It will be soon!&quot;)
          }
      }
  </code></pre>