And*_*man 5 uiviewanimation ios4
我有一些摆动UIViews的代码,就像编辑你的iOS主屏幕一样.
我有以下两种方法来实现这种摆动效果:
- (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
];
}
Run Code Online (Sandbox Code Playgroud)
当我停止摆动时,我收到警告(多次结束):
- [UIApplication beginIgnoringInteractionEvents]溢出.忽略.
然后(很多次,匹配开始的数量):
- 调用[UIApplication endIgnoringInteractionEvents]而不匹配-beginIgnoringInteractionEvents.忽略.
到底是怎么回事?如果我注释掉stopWobble动画,那很好,但自然我的动画不会停止.如果我在开始动画时删除"UIViewAnimationOptionAllowUserInteraction"选项,我会收到beginIgnoringInteractionEvents警告,但这也不好,因为我需要在这些视图摆动时与这些视图进行交互.
这种行为很好,所以我应该忽略这个吗?对我而言似乎是我应该修复的东西,只要我能找到导致它的原因.
小智 11
尝试将UIViewAnimationOptionAllowUserInteraction添加到stopWobble.我之前收到了这个错误消息,它似乎与两个动画有关,当它们未明确设置时,试图同时执行.将UIViewAnimationOptionAllowUserInteraction添加到我的第二个动画中为我解决了这个问题.
| 归档时间: |
|
| 查看次数: |
5648 次 |
| 最近记录: |