非UIView动画:动画有时不播放,UIView动画:工作正常

时间:2012-09-26 23:13:49

标签: iphone ios uiviewanimation

有时当我在设备上运行我的应用程序时,我猜大概有20%的时间,动画如:

[tableView setEditing:NO animated:YES];
[tableView setContentOffset:rect animated:YES];

[viewController0 pushViewController:viewController1 animated:YES];

不动画但立即改变。但动画如:

[UIView animateWithDuration:0.2
                     animations:^{
                         // do something
                     }
                     completion:^(BOOL finished) {
                         // do something else
                     }];

工作正常。这件事发生在其他人身上吗?不确定是什么导致它,它只发生在这个应用程序上,从未发生在任何其他应用程序上,它只是有时发生。任何帮助表示赞赏。

修改

只想澄清一下。

我使用&an; animateWithDuration'创建的动画。工作得很好。

有时来自可可的动画不会在应用运行的整个过程中播放。

3 个答案:

答案 0 :(得分:1)

尝试在推送viewcontroller之前设置UIView动画参数。

以下是一个例子:

[UIView beginAnimation:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:viewController1.view cache:NO];

[viewController0 pushViewController:viewController1 animated:YES];
[UIView commitAnimations];

答案 1 :(得分:0)

也许是因为你使用的布尔值。我的动画完全相同,但它工作正常:

[UIView animateWithDuration:4.0 animations:^(void) {
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        pfeil.alpha = 1.00;
         }];

那是我的代码......有什么问题吗?

答案 2 :(得分:0)

也许你的VC中有很多数据需要加载?如果您在主线程中加载数据,它会停止所有用户交互和UI响应一段时间。