Search code examples
ioscore-animation

When view is removed from superview all animations are removed or not?


  1. I add an endlessly repeating animation to view_A.
  2. The animation starts.
  3. I swap view_A out of its superview for view_B.
  4. The animation on view_A stops — I can tell that in my animationDidStop:finished: delegate method — and I can see [view_A.layer animationForKey:theAnimationKey] is nil, view_A.layer.animationKeys is nil and view_A.layer.animations(print view_A.layer in GDB can reveal that) is empty. (Question 1: Are all animations removed automatically when view is removed from its superview?)
  5. I swap view_A back. Here comes the odd thing: I see the animation is still going. (Question 2: how could the animation keep going after it is stopped and removed from its view?)
  6. The even more bizarre thing is that I can stop the animation after step 5 by calling [view_A.layer removeAnimationForKey:theAnimationKey]!

Solution

  • I believe it is a bug of Core Animation. Here is my radar: http://openradar.appspot.com/radar?id=6165852231565312.