Allan Jiang
Allan Jiang

Reputation: 11331

Remove long running animation when page disappear

In my view controller, I have a infinitely running UIView animation (resume itself when it stops at certain point).

When I push to other view controller, I want this animation to stop running. I am trying to insert some code in the view willdisappear method, but did not find a good way to cancel the UIView's Animation.

I am wondering what's the common practice to deal with such animation + page navigation scenario?

Thanks

Upvotes: 0

Views: 421

Answers (1)

Thompson
Thompson

Reputation: 1098

- (void) viewWillDisappear:(BOOL)animated {
    [self.view.layer removeAllAnimations];
}

If you don't have some way to communicate with the view's animation, you can remove all animations from the views layer instead.

Upvotes: 1

Related Questions