title: Custom UICollectionViewFlowLayout issue
body: <p>I have a collection view with subclassed, UICollectionViewFlow layout.
  The effect I am going for is rotation (perspective, round y axis) and scale on movement.
  My Collection view is set to paging mode ON, horizontal scrolling, every cell has full screen, that is, their frame is equal to collection view's bounds. Every cell has a table view inside.</p>
  
  <p>The problem is I am getting a weird behaviour. The table inside the cell, which is currently on screen is fine. The problem arises when I pan to the other cell. The table inside the cell seems to have its size totally wrong! It just fills half of the cell, even though the cell is much bigger. In the interface builder I set the table to stick its edges to its superviews (cell) edges (Autolayout). </p>
  
  <p>After some time, I figured the [cell layoutsubviews] is called only once after the view is instantiated. Since I am setting the UICollectionViewLayoutAttributes with a rotation straight away in that code below, could the table view be laid out with initial rotation in mind (frame of the superview shrinks as a result of heavy perspective rotation) and since [cell layoutsubiews] is never called again it just stays that way?</p>
  
  <p>Second weirdness is that callbacks from the layout do not make sense.
  collectionView:didEndDisplayingCell:forItemAtIndexPath:
  for example, tells me that the view at index path has stop being displayed, even before it ever appeared on the screen! </p>
  
  <p>Could someone try that layout, and maybe tell me what am I doing wrong?</p>
  
  <pre><code>-(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
  {
      return YES;
  }
  -(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect
  {
      NSArray* array = [super layoutAttributesForElementsInRect:rect];
  
      CGRect visibleRect;
      visibleRect.origin = self.collectionView.contentOffset;
      visibleRect.size = self.collectionView.bounds.size;
  
      for (UICollectionViewLayoutAttributes* attributes in array)
      {
          if (CGRectIntersectsRect(visibleRect, attributes.frame) &amp;&amp;
              ABS(CGRectGetMidX(visibleRect) - attributes.center.x) &lt;= self.collectionView.frame.size.width)
          {
              CGFloat distance = CGRectGetMidX(visibleRect) - attributes.center.x;
              CGFloat absoluteDistance = ABS(distance);
  
              CGFloat angle = [self normalizeFromMin:0
                                             fromMax:self.collectionView.frame.size.width
                                               toMin:0
                                               toMax:90
                                               value:absoluteDistance];
  
              CGFloat scale = [self normalizeFromMin:0
                                             fromMax:self.collectionView.frame.size.width
                                               toMin:0.7
                                               toMax:1
                                               value:absoluteDistance];
  
              CATransform3D transform = CATransform3DIdentity;
              transform.m34 = 1.0 / -1800;
              if(distance &gt; 0)
              {
                  transform = CATransform3DRotate(transform, radians(angle), 0.0, 1.0, 0.0);
              }
              else
              {
                  transform = CATransform3DRotate(transform, -radians(angle), 0.0, 1.0, 0.0);
              }
  
              transform = CATransform3DScale(transform, 1.0 - scale, 1.0 - scale, 0.0);
              attributes.transform3D = transform;
              attributes.alpha = 1.0;
  
              if(distance == 0)
              {
                  attributes.zIndex = 1;
                  attributes.transform3D = CATransform3DIdentity;
              }
              else
              {
                  attributes.zIndex = 0;
              }
          }
      }
  
      return array;
  }
  
  -(CGFloat)normalizeFromMin:(CGFloat)fromMin
                     fromMax:(CGFloat)fromMax
                       toMin:(CGFloat)toMin
                       toMax:(CGFloat)toMax
                       value:(CGFloat)toNormalize
  {
      CGFloat toBeDivided = toMin + (toNormalize - fromMin) * (toMax - toMin);
      CGFloat result = toBeDivided / (fromMax - fromMin);
      return result;
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>adding </p>
  
  <pre><code>attributes.frame = attributes.frame 
  </code></pre>
  
  <p>seems to sort of help, in terms of width, but the table inside does not seem to layout properly. It looks like size is correct, but on rotation, the cell just sort of clips the table and but the table itself just looks weird, like there was no rotation applied to it,</p>