title: Custom UICollectionViewLayout: layoutAttributesForElementsInRect asks for really little rect
body: <p>I've created my custom layout subclassing <code>UICollectionViewLayout</code>. It works exactly as I need but when the collection has only a little number of elements (like "3") the method <code>layoutAttributesForElementsInRect</code> asks information for a rectangle with <code>0 width</code>.</p>
  
  <p>This is the code of my layoutAttributesForElementsInRect implementation:</p>
  
  <pre><code>- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{
  
      NSMutableArray *results = [NSMutableArray array];
  
      for (UICollectionViewLayoutAttributes *attributes in self.elementsAttributes) {
  
          if(CGRectIntersectsRect(rect, attributes.frame)){
              [results addObject:attributes];
          }
      }
  
      return results;
  }
  </code></pre>
  
  <p>I cache the attributes in the <code>prepareLayout</code> method... so for example I have 3 elements, but the <code>rect</code> parameter that I receive from the previous function is just "impossibile", indeed it is: <code>{{0, 0}, {0, 180}}</code>. </p>
  
  <p>This happens only when I have a few cells in my collection view. </p>
  
  <p>Why and how to get attributes for all the cells that should be displayed? </p>