Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView resize and translate animation does not animate subviews correctly

I am using a UIView animation to resize and translate a view containing multiple subviews. The animation for the parent view happens perfectly; however, the subviews exhibit strange behaviour. When the animation begins, the subviews are immediately resized and then moved to their final position.

For example, if the duration and delay of the animation was five-seconds, as soon as the animation was called, the subviews would move to the desired end-of-animation values. After five-seconds, the superview would be resized and translated to the desired.

My code for the animation is:

[UIView animateWithDuration:0.5 animations:^{
    if (UIDeviceOrientationIsLandscape(self.interfaceOrientation)) {
        self.leftPaneView.frame = leftPaneLandscapeFrame;
        self.rightPaneContainerView.frame = rightPaneLandscapeFrame;
    }
    if (UIDeviceOrientationIsPortrait(self.interfaceOrientation)) {
        CGFloat offset = 300;
        self.leftPaneView.frame = CGRectOffset(leftPanePortraitFrame, -offset, 0);
        self.rightPaneContainerView.frame = rightPanePortraitFrame;
    }
}];

Any ideas?

Note: rightPaneContainerView contains the view of a UIViewController that is a child of the view controller that calls this animation.

like image 425
Eytan Avatar asked Dec 12 '11 07:12

Eytan


1 Answers

I managed to solve the problem. The content mode for some of the views was set to Left. When the animation started, the views would jump the left, and then be animated to the desired end-of-animation value.

An amateur mistake. Thanks everyone who took a look.

like image 74
Eytan Avatar answered Oct 04 '22 01:10

Eytan