title: sizeForItemAt method is not calling when using custom layout
body: <p>I am using custom layout for my collection view but if i use custom layout <code>sizeForItemAt</code> method is not calling. </p>
  
  <p>My custom layout:</p>
  
  <pre><code>public class HorizontalCollectionViewLayout : UICollectionViewLayout {
      var itemSize = CGSize(width: 0, height: 0) {
          didSet {
              invalidateLayout()
          }
      }
      private var cellCount = 0
      private var boundsSize = CGSize(width: 0, height: 0)
  
      public override func prepare() {
          cellCount = self.collectionView!.numberOfItems(inSection: 0)
          boundsSize = self.collectionView!.bounds.size
      }
      public override var collectionViewContentSize: CGSize {
          let verticalItemsCount = Int(floor(boundsSize.height / itemSize.height))
          let horizontalItemsCount = Int(floor(boundsSize.width / itemSize.width))
  
          let itemsPerPage = verticalItemsCount * horizontalItemsCount
          let numberOfItems = cellCount
          let numberOfPages = Int(ceil(Double(numberOfItems) / Double(itemsPerPage)))
  
          var size = boundsSize
          size.width = CGFloat(numberOfPages) * boundsSize.width
          return size
      }
  
      public override func layoutAttributesForElements(in rect: CGRect) -&gt; [UICollectionViewLayoutAttributes]? {
          var allAttributes = [UICollectionViewLayoutAttributes]()
          if cellCount &gt; 0 {
          for i in 0...(cellCount-1) {
              let indexPath = IndexPath(row: i, section: 0)
              let attr = self.computeLayoutAttributesForCellAt(indexPath: indexPath)
              allAttributes.append(attr)
          }
          }
          return allAttributes
      }
  
      public override func layoutAttributesForItem(at indexPath: IndexPath) -&gt; UICollectionViewLayoutAttributes? {
          return computeLayoutAttributesForCellAt(indexPath: indexPath)
      }
  
      public override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -&gt; Bool {
          return true
      }
  
      private func computeLayoutAttributesForCellAt(indexPath:IndexPath)
          -&gt; UICollectionViewLayoutAttributes {
              let row = indexPath.row
              let bounds = self.collectionView!.bounds
  
              let verticalItemsCount = Int(floor(boundsSize.height / itemSize.height))
              let horizontalItemsCount = Int(floor(boundsSize.width / itemSize.width))
              let itemsPerPage = verticalItemsCount * horizontalItemsCount
  
              let columnPosition = row % horizontalItemsCount
              let rowPosition = (row/horizontalItemsCount)%verticalItemsCount
              let itemPage = Int(floor(Double(row)/Double(itemsPerPage)))
  
              let attr = UICollectionViewLayoutAttributes(forCellWith: indexPath)
  
              var frame = CGRect(x: 0,y: 0,width: 0,height: 0)
              frame.origin.x = CGFloat(itemPage) * bounds.size.width + CGFloat(columnPosition) * itemSize.width
              frame.origin.y = CGFloat(rowPosition) * itemSize.height
              frame.size = itemSize
              attr.frame = frame
  
              return attr
      }
  }
  </code></pre>
  
  <p>And i am setting this layout at <code>viewDidLoad</code> method:</p>
  
  <pre><code>let itemWidth = 100
  let itemHeight = 100
  let horizontalCV = HorizontalCollectionViewLayout();
  horizontalCV.itemSize = CGSize(width: itemWidth, height: itemHeight)
  
  instagramCollection.collectionViewLayout = horizontalCV
  self.instagramCollection.delegate=self
  self.instagramCollection.dataSource=self
  </code></pre>
  
  <p>Other collection view methods are working fine like <code>numberOfItemsInSection</code> or <code>cellForItemAt</code> etc.  But I can't set insets or cell spacing for my collection view.</p>
  
  <p>I tried following code, <strong>below methods are not calling.</strong></p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView,
                      layout collectionViewLayout: UICollectionViewLayout,
                      sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize.init(width: (instagramCollection.frame.width / 3.0), height: instagramCollection.frame.height / 2.0)
  }
  
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -&gt; UIEdgeInsets {
      return UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
  }
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 10.0
  }
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 10.0
  }
  </code></pre>
  
  <p><strong>Also I tried to set instets and spacing from storyboard also not worked.</strong></p>
  
  <p>My collection view now using zero for all insets and spacing.</p>
  
  <p>How to fix this problem?</p>