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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With