iosobjective-cios5iconshome-button

Wiggle (shake) effect within my app is freezing the iPhone (iOS 5)


In my iOS app I have a screen with a bunch of icons that have a wiggle effect. When I press and hold one of them they start to shake (like iphone's menu) but if I press the home button (to send my app to background) the iphone freezes! After some time, it restarts itself. This is the source I'm using to do the effect:

CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[anim setToValue:[NSNumber numberWithFloat:0.0f]];
[anim setFromValue:[NSNumber numberWithDouble:M_PI/30]];
[anim setDuration:0.1];
[anim setRepeatCount:NSUIntegerMax];
[anim setAutoreverses:YES];
[self.layer addAnimation:anim forKey:@"SpringboardShake"];

And to stop:

[self.layer removeAllAnimations];

This problem only happens in iOS 5. The same code works fine in iOS 4. Any ideas about what would be making my device freezes?


Solution

  • The same problem occured with me. A solution can be found here.

    To have a smooth animation, you need to increase your calculations speed. So, one form is decreasing the things we need to calculate.