我在我的應用程序中使用動畫並感到困惑,因爲動畫在設備上滯後,模擬器上一切似乎都沒問題。首先,我試圖用UIView動畫滯後於設備
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
而在此之前提交的動畫有類似〜30行代碼以「如果」塊所以我想這可能引起問題,但後來我開始使用
[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秒(爲什麼?),然後開始動畫。但是當我在桌上查看
[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;
}];
除了在動畫之前出現意外的延遲之外,還有帶陣陣的粗糙動畫。
任何人都可以解釋爲什麼會發生,我該如何解決它?
您是否同時啓動多個動畫?而通過多個動畫我的意思是多個[UIView動畫...]在同一個方法? – Dabrut
不,只有1個動畫塊在同一時間 – Aft3rmath
我拿起了確實有多個代碼的代碼。爲什麼這不好? – cynistersix