简体   繁体   English

animateWithDuration动画是非常不可预测的

[英]Animation is very unpredictable with animateWithDuration

This question is asked a lot of people but I have not really found the answer to it. 很多人都问这个问题,但我还没有真正找到答案。

I have some class where inside many other methods with animation 我有一些在其他许多动画方法里面的类

someClass.m
@implementation

////..

-(void) someAnimationWithSomeObject (someParameters...blablabla

    [UIView animateWithDuration:0.2f
                          delay:delay
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^
     {
         self.center = point;
         self.transform = CGAffineTransformMakeRotation(_angle);
     }
                     completion:nil)];

in ViewController 在ViewController中

-(void) someMethod1 {
/.....


for (int i=0; i < count; i++) {

/...some operation with coordinates

        [self.cardContainer addSubview:someView];

        [someView someAnimationWithSomeObject:someParameters withDelay:delay];
        delay += 0.2f; 
/... }

[self someMethod2]; [self someMethod2];

}

-(void) someMethod2 {
/.....


for (int i=0; i < count; i++) {

/...some operation with coordinates

        [self.cardContainer addSubview:someView];

        [someView someAnimationWithSomeObject:someParameters withDelay:delay];
        delay += 0.2f; 
/... }

}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self someMethod1];

}

When I use this code animation is very unpredictable, because when call someMethod2 calculation of coordinates is fastest then animation. 当我使用此代码时,动画是非常不可预测的,因为在调用someMethod2 ,坐标的计算someMethod2动画快。

how to make the animation to play in the first method and then in the second in etc. 如何使动画在第一种方法中播放,然后在第二种方法中播放,等等。

[solved] [解决了]

after someMethod1 adding 在someMethod1添加之后

 [self performSelector:@selector(someMethod2) withObject:nil afterDelay:delay];

and need some correction with delay + or - 需要延迟+或-

it's well done! 做得好!

Consider starting the second method in the completion block of the first. 考虑在第一个方法的完成框中启动第二个方法。 That is, "Do this animation; then, when it's finished, call someMethod2 and start the next animation. 也就是说,“执行此动画;然后在完成动画后,调用someMethod2并开始下一个动画。

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

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