简体   繁体   English

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

[英]non UIView animation: animations not playing sometimes, UIView animation: working fine

Sometimes when I run my app on the device, I guess about 20% of the time, animations such as: 有时当我在设备上运行我的应用程序时,我猜大概有20%的时间,动画如:

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

and

[viewController0 pushViewController:viewController1 animated:YES];

do not animate but instantly change. 不动画但立即改变。 But animations such as: 但动画如:

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

Work fine. 工作正常。 Has this happened to anybody else? 这件事发生在其他人身上吗? Not sure what could be causing it, it only happens on this one app, never happened on any other app and it only happens sometimes. 不确定是什么导致它,它只发生在这个应用程序上,从未发生在任何其他应用程序上,它只是有时发生。 Any help appreciated. 任何帮助赞赏。

Edit: 编辑:

Just want to clarify. 只想澄清一下。

Animations that i create with 'animateWithDuration' work fine. 我使用'animateWithDuration'创建的动画效果很好。

Sometimes animations from cocoa don't play for the entire time the app is running. 有时,来自可可的动画在应用程序运行的整个过程中都不会播放。

Try to set the UIView animation parameters before you push your viewcontroller. 在推送viewcontroller之前尝试设置UIView动画参数。

Here's an example: 这是一个例子:

[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];

Maybe it's because of the boolean u used. 也许这是因为你使用的布尔值。 My animation is quite the same but it's working fine: 我的动画完全相同,但工作正常:

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

thats my code...any questions? 那是我的代码...有什么问题吗?

Maybe you have a lot of data to load in your VC? 也许你的VC中有很多数据需要加载? if you load your data in main thread it stops all user interactions and UI responses for a while. 如果您在主线程中加载数据,它会停止所有用户交互和UI响应一段时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM