我有一些动画会在加载根视图控制器时自动启动。这些动画包含在viewDidLoad
中。当我导航到我的下一个视图控制器并返回到根视图控制器时,所有动画都停止了。当我按“home”按钮然后返回到视图时,会发生相同的行为。动画在视图控制器之间移动时不会重新启动
我确定我在这里错过了一些非常基本的东西,但会很感激任何帮助。谢谢。
编辑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) {
}];
}];
}
你正在做什么类型的动画(动画核心,UIView的animation.opengl等)以及什么事件? –
道歉,我会更新OP – garethdn
你必须在viewDiDA中做同样的动作,因为itgets在切换views.call [self beeBobbing]; in viewDidAppear –