0

I have made a custom activity indicator to use in a project. I rotate a static loader image for that.

- (void) rotate {
    lastInstance++;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(rotate)];
    [UIView setAnimationDuration:0.1];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    spinnerImageView.layer.transform = CATransform3DMakeRotation(M_PI*(lastInstance%10)/5, 0.0, 0.0, 1.0);
    [UIView commitAnimations];
}

The spinnerimageview is contained within a superview container, and it bears the static loader image. It works fine, except for crashing unpredictably without any error messages.

Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
Sonu Jha
  • 719
  • 3
  • 13
  • 23

1 Answers1

1

Looks like you're stuck in a never ending recursion. How do you decide when to stop the rotation?

Each time the rotation animation completes it simply calls rotate again, with seemingly no end in sight.

The crash you are seeing is likely a stack overflow (how apt).

I'd suggest rethinking how to you decide whether the animation could continue.

Jasarien
  • 58,279
  • 31
  • 157
  • 188
  • yes...it keeps on rotating indefinitely, i just show and hide it when needed – Sonu Jha Jan 14 '13 at 10:46
  • Then that's almost surely what's happening. You'll need to rewrite so that you're not infinitely recursing. I'd suggest using a timer which repeatedly triggers the rotate method as opposed to using the animation delegate to recall the same method it's in. – Jasarien Jan 14 '13 at 11:18
  • The timer is good advice. Also, do not set the delegate http://stackoverflow.com/questions/13794562/sigsegv-segv-accerr-crash-reports-what-to-do/17184663#17184663 then when implementing the NSTimer, see http://stackoverflow.com/questions/6098146/what-caused-this-iphone-crash-log/17202550#17202550 – MoDJ Jun 20 '13 at 22:43