title: How to count number of uicollectionview's rows in swift
body: <p>I need to determine uicollectionview's height.</p>
  <pre><code>let layout = contactCollectionView.collectionViewLayout
  let heightSize = String(Int(layout.collectionViewContentSize.height))
  </code></pre>
  <p>The above solution works on some situations in my project. In this specific situation I need to count number of rows and then multiple it with a number to find height.</p>
  <pre><code>func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          // height = (count rows) * 30 . every cell height is 30 
          // every cell has different width.
          return (presenter?.selectedContact.count)!
      }
  </code></pre>
  <p><strong>How can I find number of rows?</strong></p>
  <p><strong>Update</strong></p>
  <p>Look at the image.
  <a href="https://i.stack.imgur.com/UXIgG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UXIgG.png" alt="enter image description here" /></a></p>
  <p>This is my collectionView. Every cell has different width(because it is string). So It has different rows. The width of this collectionView is width of <strong>view.frame</strong></p>