UIView动画在设备上滞后 [英] UIView animation lags on device
问题描述
我在我的应用程序中使用动画并感到困惑,因为动画滞后于设备,在模拟器上一切正常.首先,我尝试使用
I'm using animation in my app and get confused, because animation is lagging on device, on simulator everything seems OK. First I tried to use
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
在提交动画之前,大约有30行带有"if"块的代码,所以我认为这可能会导致问题,但是随后我开始使用
And before commit animation there were something like ~30 lines of code with "if" blocks so I thought this might cause the problem, but then I start to use
[UIView animateWithDuration:0.3
delay:0.0
options: UIViewAnimationCurveEaseIn
animations:^{
mainView.frame = CGRectMake(0, 0, 320, 420);
buttonsView.transform = CGAffineTransformMakeTranslation(0, 68);
radioBar.transform = CGAffineTransformMakeTranslation(0, -50);
vk_controller.view.frame = CGRectMake(0, 0, 320, 440);
}
completion:^(BOOL finished){
button.isHiddenDown = YES;
}];
以"if"为单位,但滞后似乎仍然存在.当我按下按钮时,会有〜0.5-1秒的延迟(为什么?),然后动画开始.但是当我在表格视图中
in terms of "if" blocks, but lags seems to stay. When I press button there is delay ~0.5-1 sec (why?) and then animation starts. But when I'm on table view
[UIView animateWithDuration:0.3
delay:0.0
options: UIViewAnimationCurveEaseIn
animations:^{
mainView.frame = CGRectMake(0, 0, 320, 420);
buttonsView.transform = CGAffineTransformMakeTranslation(0, 68);
radioBar.transform = CGAffineTransformMakeTranslation(0, -50);
goha_news_controller.view.frame = CGRectMake(0, 0, 320, 420);
goha_news_controller.feed_table.frame = CGRectMake(0, 0, 320, 420);
if(goha_news_controller.backgroundView)
{
goha_news_controller.backgroundView.frame = CGRectMake(0, 0, 320, 420);
goha_news_controller.newsDetailView.frame = CGRectMake(0, 0, 320, 420);
}
}
completion:^(BOOL finished){
button.isHiddenDown = YES;
}];
除了动画出现意外延迟之外,还有带有突发性的刺耳动画.
谁能解释为什么会发生以及如何解决?
in addition to the unexpected delay before the animation, there is harshness animation with bursts.
Can anyone explain why does it happen and how can I fix it?
推荐答案
另一个可能的原因.您是否在任何屏幕视图或图层中使用阴影? iOS根本无法很好地处理阴影动画.
Another possible cause. Are you using shadows in any of the on-screen views or layers? iOS does not handle animating with shadows very well at all.
这篇关于UIView动画在设备上滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!