【发布时间】:2011-11-19 17:44:58
【问题描述】:
我正在尝试为一个空的表单域设置一个指示器的动画,所以我使用下面的方法来设置一个位置的动画,反转动画,然后重复。在模拟器中,这工作正常,在我的 3GS 上,当调用完成块时,它看起来好像有一个闪烁。指示器会短暂显示在中间位置,而不是回到它的原点。
对为什么会发生这种情况有任何想法吗?谢谢。
- (void)bounceFormIndicator {
if (formIndicator.superview == nil) {
return;
}
int bounceDistance = 24;
[UIView animateWithDuration:0.6
delay:0
options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction
animations:^{
CGRect indicatorFrame = formIndicator.frame;
indicatorFrame.origin.x += bounceDistance;
formIndicator.frame = indicatorFrame;
}completion:^(BOOL finished){
CGRect indicatorFrame = formIndicator.frame;
indicatorFrame.origin.x -= bounceDistance;
formIndicator.frame = indicatorFrame;
[self bounceFormIndicator];
}];
}
【问题讨论】:
-
仍未解决,但我找到了解决方法。我使用 UIViewAnimationOptionRepeat 选项并完全删除完成块。