【发布时间】:2011-11-15 00:49:21
【问题描述】:
我使用 UIView 动画在屏幕周围随机设置 5 个方块 (UIButtons)。根据用户的选择,可以看到 2 到 5 个正方形。当只有 2 个可见时,其他三个的隐藏值设置为 YES,因此它们实际上仍在动画中(对吗?),它们只是不可见。但是当只有 2 个可见时,动画是平滑的,但是当所有 5 个都可见时,动画会变得不稳定。我不确定如何描述它,因为方块仍在以正确的速度移动并移动到正确的点;波涛汹涌并不可怕,只是糟糕到足以引起注意。有没有办法摆脱它?这是我用来为正方形设置动画的代码:
编辑:将动画更改为阻止:
[UIView animateWithDuration:animationSpeed
delay:0
options:UIViewAnimationOptionCurveLinear
animations:^{
view.center = destPoint;
}
completion:^(BOOL finished){
if([view isEqual:squareThree])
[self moveBadGuys];
}
];
/*for(UIButton* button in squareArray) {
if(!shouldMove)
return;
[UIView beginAnimations:@"b" context:nil];
[UIView setAnimationDuration:animationSpeed];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
view.center = destPoint;
[UIView commitAnimations];
}*/
编辑:呈现这个的视图是三个 UIViewController 堆栈中的第三个
ViewController* controller = [[[ViewController alloc] init] autorelease];
[self presentModalViewController:controller animated:NO];
这种呈现视图的方式会占用内存吗?
【问题讨论】:
-
会不会是你内存不足?
-
我是这么想的,我不太了解 iPhone 必须使用多少内存,或者创建单个 IBOutlet 会消耗多少资源,但我确实有很多该视图控制器中的 IBOutlets
-
不,呈现视图的方式不会占用内存。尝试一次只做一个动画,而不是 for 语句,看看是否仍然出现断断续续的情况。
-
是的,这停止了波动,这对我来说没有意义,因为即使只有两个方格在移动(而且并不波动),其他方格也被隐藏了,但仍在移动,对吧?
-
我有点困惑,这解决了你的问题吗?如果没有,如果你想让不可见的物体移动到一个特定的点,不要动画它,只做 CGPointMake。
标签: ios core-animation uiviewanimation quartz-core