Is animation automatically removed from layers when switching viewcontrollers?

I set up a simple CAKeyframeAnimation with infinite repetition and added it to the layer. Everything is fine, except that the animation is deleted when I switch to another tab (or, most likely, any other mechanism for changing the active view controller).

Is this documented somewhere, possibly new in iOS 5, and is there a different solution than starting the animation again in viewWillAppear? In this case, the time base does not matter, starting with the animation from time 0 would be nice.

+4
source share
1 answer

You do not have to do any work with View while it is not on the screen, because it is simply a waste of iPhone resources. In addition, your application may receive a memory warning, and the view will be unloaded. IMHO the best approach is to set up the graphics in -(void) viewWillAppear and start the animation in -(void) viewDidAppear .

PS In -(void) viewDidLoad parameters of the view frame are still invalid, and if you try to use them, you may get something wrong.

-1
source

All Articles