Ios 视图控制器加载时的视图动画

Ios 视图控制器加载时的视图动画,ios,objective-c,xcode,Ios,Objective C,Xcode,当加载一个ViewController时,我正在执行动画。我在viewdidappease方法中调用它。看起来像这样 [UIView animateKeyframesWithDuration:2.5f delay:0.0f options:0 animations:^{ [UIView addKeyframeWithRelativeStartTime:0.0f relativeDuration:1.0f animations:^{ CGRect rocke

当加载一个ViewController时,我正在执行动画。我在viewdidappease方法中调用它。看起来像这样

[UIView animateKeyframesWithDuration:2.5f delay:0.0f options:0 animations:^{
        [UIView addKeyframeWithRelativeStartTime:0.0f relativeDuration:1.0f animations:^{
            CGRect rocketFrame = _rocketImageView.frame;
            rocketFrame.origin.y = rocketFinishPosition;
            _rocketImageView.frame = rocketFrame;

            CGRect flameFrame = _flameImageView.frame;
            flameFrame.origin.y = rocketFinishPosition + rocketFrame.size.height - 3;
            _flameImageView.frame = flameFrame;
            _flameImageView.hidden = false;

            CGRect earthFrame = _earthImageView.frame;
            earthFrame.origin.y = earthFinishPosition;
            _earthImageView.frame = earthFrame;

                CGRect moonFrame = _moonImageView.frame;
                moonFrame.origin.y = moonFinishPosition;
                _moonImageView.frame = moonFrame;
        }];

        [UIView addKeyframeWithRelativeStartTime:0.0f relativeDuration:0.6f animations:^{
            _flameImageView.transform = CGAffineTransformMakeScale(1.f, 1.f);
        }];
    } completion:nil];
问题是,当我第一次加载ViewController时,动画将播放,但当完成时,动画将捕捉回起始位置。但是,如果我离开ViewController并再次返回,动画将播放,更改将保持不变

我的问题

我的子视图是否播放了两次


何时可以确定我的ViewController已完成加载?

假设没有自动布局,在完成块中,将视图属性设置为最终的所需状态

// taking the rocket frame as an example:
CGRect rocketFrame = _rocketImageView.frame;  // do this with the other frames, too

[UIView animateKeyframesWithDuration:2.5f delay:0.0f options:0 animations:^{
        [UIView addKeyframeWithRelativeStartTime:0.0f relativeDuration:1.0f animations:^{

            rocketFrame.origin.y = rocketFinishPosition;
            _rocketImageView.frame = rocketFrame;

            CGRect flameFrame = _flameImageView.frame;
            flameFrame.origin.y = rocketFinishPosition + rocketFrame.size.height - 3;
            _flameImageView.frame = flameFrame;
            _flameImageView.hidden = false;

            CGRect earthFrame = _earthImageView.frame;
            earthFrame.origin.y = earthFinishPosition;
            _earthImageView.frame = earthFrame;

                CGRect moonFrame = _moonImageView.frame;
                moonFrame.origin.y = moonFinishPosition;
                _moonImageView.frame = moonFrame;
        }];

        [UIView addKeyframeWithRelativeStartTime:0.0f relativeDuration:0.6f animations:^{
            _flameImageView.transform = CGAffineTransformMakeScale(1.f, 1.f);
        }];
    } completion:^(BOOL finished) {
         // do this with the other frames, too
        _rocketImageView.frame = rocketFrame;
    }];