Iphone 获取UIView块动画的完整布尔回调延迟(animateWithDuration)

Iphone 获取UIView块动画的完整布尔回调延迟(animateWithDuration),iphone,objective-c,ios5,core-animation,xcode4.2,Iphone,Objective C,Ios5,Core Animation,Xcode4.2,我在做块动画,我的项目是使用opengl进行游戏,uiview用于菜单类的东西 我使用animateWithDuration方法为uiview制作动画,bt在获得延迟完成动画布尔回调时面临问题。我在UIKit应用程序中尝试了相同的代码,它运行得非常顺利 下面是我的代码: -(void) playAnimation:(UIButton *)_button atPosition:(CGRect)_rect withDuration:(CGFloat)_duration andDelay:(CGFlo

我在做块动画,我的项目是使用opengl进行游戏,uiview用于菜单类的东西

我使用animateWithDuration方法为uiview制作动画,bt在获得延迟完成动画布尔回调时面临问题。我在UIKit应用程序中尝试了相同的代码,它运行得非常顺利

下面是我的代码:

-(void) playAnimation:(UIButton *)_button atPosition:(CGRect)_rect withDuration:(CGFloat)_duration andDelay:(CGFloat)_delay andDiection:(NSInteger)_direction
{
    [UIView animateWithDuration:_duration
                          delay:_delay
                        options:UIViewAnimationCurveLinear     
                     animations:^{ 
                         _button.frame = _rect;
                     }
                     completion:^(BOOL finished){
                         [UIView animateWithDuration:0.1
                                               delay:0.0
                                             options:UIViewAnimationCurveEaseInOut     
                                          animations:^{ 
                                              CGRect rect = _rect;

                                              rect.origin.x = _rect.origin.x + (10 * _direction); 
                                              _button.frame = rect;
                                          }
                                          completion:^(BOOL finished){
                                              [UIView animateWithDuration:0.1
                                                                    delay:0.0
                                                                  options:UIViewAnimationCurveEaseInOut     
                                                               animations:^{ 
                                                                   _button.frame = _rect;
                                                               }
                                                               completion:^(BOOL finished){

                                                               }];

                                          }];
                     }];
}

关键帧动画可能比嵌套块更有意义。块动画有什么问题?在uikit应用程序中效果很好,那么为什么不在opengl应用程序中呢?gerry3,我尝试了关键帧动画,效果很好,但问题是它在完成后变得不可见…有什么帮助吗?在上面的代码中,如果我注释_button.frame=_rect,我会得到分段错误;错误得到解决,但我需要这段代码,因为我正在设置屏幕中间的位置。为什么我不能进入第三个街区的按钮和按钮。在第二个块中可以访问这些…这是块动画的限制吗?你在主线程上运行吗?您是否正确管理内存?我假设您使用的是ARC?对于关键帧动画,我认为您需要在完成块/方法中设置最终位置。否则,它将恢复到您所称的“不可见”的起始位置。