【问题标题】:animation completion called immediately立即调用动画完成
【发布时间】:2011-05-16 22:13:48
【问题描述】:

我有以下动画块:

[UIView animateWithDuration:2 
                 animations:^{ 
                     [childViewController_.view setAlpha:0];  
                 } 
                 completion:^(BOOL finished) {
                     [childViewController_.view removeFromSuperview];
                 }];

如上执行时,立即调用完成块。 但是,如果我没有完成块,则动画将按预期执行。

我在这里做错了什么?

更新
完成块中的finished 标志是NO

【问题讨论】:

  • 函数的finished参数接收的是什么?会不会有其他东西打断了动画?
  • 你是对的 - 它返回 NO。我怎么知道这是什么原因?
  • 我也遇到了同样的问题,你最终找到解决方案了吗?
  • 如果你的动画被打断,可能会返回NO。
  • 您的视图是否有可能被发布?

标签: iphone ipad objective-c-blocks uiviewanimation


【解决方案1】:

你只是忘了检查一个条件

[UIView animateWithDuration:2 
                 animations:^{ 
                     [childViewController_.view setAlpha:0];  
                 } 
                 completion:^(BOOL finished) {
                     if (finished)
                     {
                          [childViewController_.view removeFromSuperview];
                     }
                 }];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多