Calling [self.view layoutIfNeeded];
in the animation block causes all of its child views to animate.
This causes a problem whilst scrolling a UICollectionView
because the UICollectionViewCells
animates onto the screen.
Is there anyway I can stop the Portsmouth
cell from animating in?
** EDIT **
To add insult to injury I am animating the constraints that are controlling the height of the UICollectionView
. To increase the size of the feed, I have a disappearing UIView
acting like a header.
You can layoutIfNeeded
on any view, so perhaps consider changing the view hierarchy of your cell to isolate the view that contains the constraints that need animating. So that your layoutIfNeeded
call only triggers animations on the constraints you intend to animate. Does that make sense?
This would mean inserting a UIView into your hierarchy, and this view would become the superview of the views you are animating via constraints.
I've spent hours trying to fix this bug, and finally I've found a solution:
[UIView setAnimationsEnabled:NO];
// Layout cell
[UIView setAnimationsEnabled:YES];
I've been using frames, not auto-layout, but maybe there's a way to disable animations for constraint layouting too.
EDIT:
You could try:
-(void)layoutSubviews
{
[UIView setAnimationsEnabled:NO];
[super layoutSubviews];
[UIView setAnimationsEnabled:YES];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With