ios – 我的animatewithduration,完成块只执行一次

ios – 我的animatewithduration,完成块只执行一次,第1张

概述我使用下面的代码块向下滑动UIView,完成后再旋转另一个UIView. 动画的第二部分,完成块仅执行一次,这意味着第一个动画未完成,否则它将到达完成块. 在iPhone模拟器上,它看起来好像第一个动画完成了…… 任何人都可以帮我解决这个问题吗? 我的NSLog说: finished 1st started 2nd finished 1st finished 1st finished 1st . 我使用下面的代码块向下滑动UIVIEw,完成后再旋转另一个UIVIEw.
动画的第二部分,完成块仅执行一次,这意味着第一个动画未完成,否则它将到达完成块.
在iPhone模拟器上,它看起来好像第一个动画完成了……
任何人都可以帮我解决这个问题吗?
我的NSLog说:

finished 1st

started 2nd

finished 1st

finished 1st

finished 1st
.
.
.

- (IBAction) move { [UIVIEw animateWithDuration:0.7 animations:^{    [UIVIEw beginAnimations:nil context:NulL];    [UIVIEw setAnimationDuration:0.7];    [UIVIEw setAnimationRepeatCount:1];    [UIVIEw setAnimationRepeatautoreverses:NO];    CGPoint pos = movingttable.center;    float movedistance = 220.0;    if(!isVIEwVisible){        //expose the vIEw        pos.y = pos.y+movedistance;        //disable selection for xy table        xtable.userInteractionEnabled = NO;        ytable.userInteractionEnabled = NO;        //angle = M_PI;    }    else    {        pos.y = pos.y-movedistance;        xtable.userInteractionEnabled = YES;        ytable.userInteractionEnabled = YES;        //angle = -M_PI;    }    isVIEwVisible = !isVIEwVisible;    movingttable.center = pos;          NSLog(@"finished 1st");}completion:^(BOol finished){    NSLog(@"started 2nd");        [UIVIEw animateWithDuration:0.4 animations:^{            //[UIVIEw beginAnimations:nil context:NulL];            [UIVIEw setAnimationDuration:0.4];            //[UIVIEw setAnimationRepeatCount:1];            //[UIVIEw setAnimationRepeatautoreverses:NO];            arrows.transform = CGAffinetransformMakeRotation(angle);          }completion:^(BOol finished){             angle = -angle;         }];}];
解决方法 为什么要尝试在animateWithDuration块代码中初始化另一个UIVIEw动画?将代码更新为以下内容,并确保一次不执行单个视图的多个动画.

- (IBAction) move { [UIVIEw animateWithDuration:0.7 animations:^{    CGPoint pos = movingttable.center;    float movedistance = 220.0;    if(!isVIEwVisible){        //expose the vIEw        pos.y = pos.y+movedistance;        //disable selection for xy table        xtable.userInteractionEnabled = NO;        ytable.userInteractionEnabled = NO;        //angle = M_PI;    }    else    {        pos.y = pos.y-movedistance;        xtable.userInteractionEnabled = YES;        ytable.userInteractionEnabled = YES;        //angle = -M_PI;    }    isVIEwVisible = !isVIEwVisible;    movingttable.center = pos;          NSLog(@"finished 1st");}completion:^(BOol finished){    NSLog(@"started 2nd");        [UIVIEw animateWithDuration:0.4 animations:^{            arrows.transform = CGAffinetransformMakeRotation(angle);          }completion:^(BOol finished){             angle = -angle;         }];}];

BTW:如果你问我:)块代码需要一些严肃的重构

总结

以上是内存溢出为你收集整理的ios – 我的animatewithduration,完成块只执行一次全部内容,希望文章能够帮你解决ios – 我的animatewithduration,完成块只执行一次所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1051853.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存