1
votes

I have an instance of [UIView animateWithDuration: delay: options: animations: completion:] within a scrollViewDidEndDecelerating method that resizes a UIView to be a smaller height if the contentOffset is greater than 0.

For some reason, the frame doesn't stay the way it should on the second scroll. Meaning that despite the resize and the visible change in the frame, the frame jumps to it's larger height and reanimates back to the smaller height. This only seems to happen the second time scrolling, but it retains the desired height henceforth, throughout the lifecycle of the app.

I have no frame changes done other than in my instances of [UIView animateWithDuration: delay: options: animations: completion:], so why does this frame not stay the way it should at that time?

I like to point out that the scrollView is actually a horizontal collectionView, here is the code:

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
CGFloat offset = self.collectionView.contentOffset.x;
if(offset == 0){
    [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{

        self.headingView.frame = CGRectMake(0, 0, 320, 95);

    } completion:^(BOOL finished){

    }];        

}else if(self.headingView.frame.size.height != 60){
    [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{

        self.headingView.frame = CGRectMake(0, 0, 320, 60);

    } completion:^(BOOL finished){

    }];
}
}
Can you upload the project? It's hard to understand a problem with scrolls and animations by reading it. - Marcos Griselli