title: Trying to make off-screen UICollectionViewCells pre-render using a custom layout
body: <p>I have a paged UICollectionView, with one cell per page. However, my UICollectionViewCells are slow to render (third party library, no options there). So as an optimisation, i need to pre-render the cells to the left and right of the current page, so scrolling is smooth.</p>
  
  <p>What i've done is, inside my custom UICollectionViewLayout, is outset the passed rect by 1 point before checking to see which cells' UICollectionViewLayoutAttributes should be returned, see here:</p>
  
  <pre><code>- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
      CGRect outsetRect = CGRectInset(rect, -1, 0);
      return [_myAttributes filter:^BOOL(UICollectionViewLayoutAttributes *attribs) {
          return CGRectIntersectsRect(attribs.frame, outsetRect);
      }];
  }
  </code></pre>
  
  <p>This works as expected. However, when the actual UICollectionView does its thing, it seemingly ignores the offscreen cells and calls <code>cellForItemAtIndexPath</code> only for the first cell, not the cell to the right (or left).</p>
  
  <p>Any ideas what is going on? Thanks</p>