non UIView animation: animations not playing sometimes, UIView animation: working fine

試著忘記壹切 提交于 2019-12-12 09:46:08

问题


Sometimes when I run my app on the device, I guess about 20% of the time, animations such as:

[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.

Sometimes animations from cocoa don't play for the entire time the app is running.


回答1:


Try to set the UIView animation parameters before you push your viewcontroller.

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



回答2:


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?




回答3:


Maybe you have a lot of data to load in your VC? if you load your data in main thread it stops all user interactions and UI responses for a while.



来源:https://stackoverflow.com/questions/12611841/non-uiview-animation-animations-not-playing-sometimes-uiview-animation-workin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!