Animations not restarting when moving between view controllers
animation, ios, iphone, objective-c, uiviewcontroller
Solution
i think if you give all animation in `viewWillAppear:` then its work fine... thats it... :)
Problem
I have a number of animations that start automatically when my root view controller is loaded. These animations are included in `viewDidLoad`. When i navigate to my next view controller and return to the root view controller, all the animations have stopped. The same behaviour occurs when i press the "home" button and then return to the the view. I'm sure i'm missing something very basic here but would appreciate any help. Thanks. EDIT 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) { }]; } ``` EDIT 2: This type of animation seems to restart when changing between views: ``` -(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) { }]; }]; } ```