I have a UICollectionView
in UISplitViewController
with a custom UICollectionViewLayout
which implements:
prepareLayout
to store the attributes with right frames (based on orientation);collectionViewContentSize
to return the right collection view size based on the orientationlayoutAttributesForItemAtIndexPath
just returns the stored attributeslayoutAttributesForElementsInRect
check for the intersections
My layout looks like this in portrait mand landscape mode:
Now, the problem is that when I change the orientation of the screen, I use this function to trigger the layout update:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[headlinesCollectionView performBatchUpdates:nil completion:nil];
}
and this changes instantly the cell frame size to the new one; however the cell position get animated. Before trying this I used invalidateLayout
, which does even a worse job since it doesn't animate either the size or the position.
Any idea on how I could make this work? The cell should get resized AND move whilst the animation occurs.