Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 4.2 Block Animation --> Why do I get these warnings: -[UIApplication beginIgnoringInteractionEvents] overflow. Ignoring

I've got some code that wobbles UIViews, much like when you edit your iOS home screens.

I have the 2 following methods to achieve this wobble effect:

- (void)wobble {
 int amountInRadians = (self.tag % 2) == 0 ? 2.0 : -2.0;
 containerView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-amountInRadians));

 [UIView animateWithDuration:0.10 
        delay:0.0 
      options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)
      animations:^ {
       containerView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(amountInRadians));
      }
      completion:NULL
 ];
}

- (void)stopWobble {
 [UIView animateWithDuration:0.01
        delay:0.0 
      options:(UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)
      animations:^ {
       containerView.transform = CGAffineTransformIdentity;
      }
      completion:NULL
  ];
}

When I stop the wobble, I get the warning (many times over):

-[UIApplication beginIgnoringInteractionEvents] overflow. Ignoring.

then (many times over, matching number of begin ones):

-[UIApplication endIgnoringInteractionEvents] called without matching -beginIgnoringInteractionEvents. Ignoring.

What on earth is going on? If I comment out the stopWobble animation, it's fine, but naturally my animations don't stop. If I remove the "UIViewAnimationOptionAllowUserInteraction" option when I begin the animation, I get the beginIgnoringInteractionEvents warning, but this is also no good because I need to interact with these views while they wobble.

The behaviour works fine, so should I just ignore this? Seems to me like something I should fix, if only I can find out what causes it.

like image 372
Andrew Jackman Avatar asked Nov 03 '10 18:11

Andrew Jackman


1 Answers

Try adding UIViewAnimationOptionAllowUserInteraction to stopWobble. I've gotten that error message before and it seems to have to do with two animations trying to execute simultaneously when they are not explicitly set to do so. Adding UIViewAnimationOptionAllowUserInteraction to my second animation fixed this problem for me.

like image 97
Eric Corriel Avatar answered Oct 20 '22 18:10

Eric Corriel