Flicker while using layoutIfNeeded on containerview

| | August 7, 2015

I have a controller in storyboard that consist of two container views. I set the vertical distance between the two containers to zero.

What I want is to change the height constraint of one of the container at run time.

Here is the code for changing the constraint:

[UIView animateWithDuration:kAnimationDuration animations:^{
    self.offeringContainerHeightConstraint.constant = [SJDataManager shared].offeringItems.count * kOfferingCellHeight + kOfferingHeaderHeight;
    [self.view layoutIfNeeded];

The issue is, the other container view moves before so there is blank area between the two containers until the animation completes.

I want that two container views should change their constraint value in synchronisation so that this flicker can be removed.

One Response to “Flicker while using layoutIfNeeded on containerview”

  1. I have finally found the solution for this. Actually it was the difference between the expectedHeightForRowAtIndexPath and heightForRowAtIndexPath. As the height returned by these two methods are different that is why I am getting the flicker.

Leave a Reply