0

Animation or something else will cost CPU. If a ViewController not on screen, e.g. The ViewController not at the top of the navigation stack. Should I stop them to reduce CPU cost? Will it enhance the performance of my apps? What is the best practices to do this? any blogs about this?

I searched whth google, but find nothing.

Any reply will be appreciate, thanks in advance.

1 Answers1

0

Yes, you should stop animation if it is not visible.
You can do it in different places based on your implementation. I don't know what kind of animations are you using (based on OpenGL, timer, CAAnimation or other technologies), but next methods are common:

  1. Method of a Application Delegate "Application will resign Active".
  2. Method of a ViewController "View will disappear" or "View did disappear".
  3. Method of a View "Will move to window" or "Did move to window", when destination window == nil.

Also do not't forget that CAAnimations is stopped by system then your application moves to background.

Community
  • 1
  • 1
Andrew Romanov
  • 4,774
  • 3
  • 25
  • 40