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

StackOverflow https://stackoverflow.com/questions/4090286

  •  28-09-2019
  •  | 
  •  

Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

I guess it happens when you have too many views that will animated at the same time, like a grid of custom views in viewDidAppear.

a. Under iOS4 they all try to disable UIApplication interactions at the same time and to avoid problems UIApplication overflows and ignores some of them.

b. After animating all views tell again UIApplication to enable interactions but UIApplication doesn't recognize some of the enable calls as they were ignored in (a).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top