当我的根视图控制器加载时,我有许多动画会自动启动。这些动画包含在viewDidLoad
. 当我导航到下一个视图控制器并返回根视图控制器时,所有动画都停止了。当我按下“主页”按钮然后返回视图时会发生相同的行为。
我确定我在这里遗漏了一些非常基本的东西,但如果有任何帮助,我将不胜感激。谢谢。
编辑 1:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self beeBobbing];
//animate the butterfly oscillating
[self butterflyOscillate];
}
-(void) beeBobbing
{
[UIView animateWithDuration:1.0f delay:0 options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction ) animations:^{
CGPoint bottomPoint = CGPointMake(215.0, 380.0);
imgBee.center = bottomPoint;
} completion:^(BOOL finished) {
}];
}
编辑 2:这种类型的动画在视图之间切换时似乎会重新启动:
-(void) animateClouds
{
[UIView animateWithDuration:30.0f delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
CGPoint leftScreenCenter = CGPointMake(-420.0, 119.0);
imgClouds.center = leftScreenCenter;
} completion:^(BOOL finished) {
CGPoint rightScreenCenter = CGPointMake(1450.0, 119.0);
imgClouds.center = rightScreenCenter;
[UIView animateWithDuration:40.0f delay:0 options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionRepeat) animations:^{
CGPoint leftScreenCenter = CGPointMake(-420.0, 119.0);
imgClouds.center = leftScreenCenter;
} completion:^(BOOL finished) {
}];
}];
}