2013-03-02 51 views
0

我正在使用基于块的动画模拟作为游戏的介绍动画的交易卡。动画效果很好,除非用户在动画过程中导致一个segue发射,我们执行额外的动画以获得从源到目标视图控制器的“滑动”转换。现在发生的事情是,已经被“处理”的卡片适当地滑出屏幕,并且如果有没有处理过的卡片,它在转换的中间处理它,然后当目标视图控制器被按下时卡片消失。这很丑陋。中断完成块基于动画执行单独的动画

我已经尝试'view.layer removeAllAnimations'没有帮助(我没有进口quartzcore)。我想要做的是取消完成块中未完成的动画,并简单地执行segue动画。

这里的“交易”代码:

[UIView animateWithDuration:0.20f 
        delay:0.20f 
       options:UIViewAnimationOptionCurveEaseOut 
      animations:^ 
{ 
_fiveOfHearts.center = CGPointMake(90, 198); 
_fiveOfHearts.transform = fiveOfHeartsTransform; 
} 

      completion:^(BOOL finished) 
{[UIView transitionWithView:_fiveOfHearts duration:0.20f options:UIViewAnimationOptionTransitionFlipFromRight animations:^{ 
    _fiveOfHearts.image = [UIImage imageNamed:@"52"]; 
}completion:nil]; 
[UIView animateWithDuration:0.30f 
        delay:0.0f 
        options:UIViewAnimationOptionCurveEaseOut 
       animations:^ 
    { 
    _jackOfHearts.center = CGPointMake(128, 196); 
    _jackOfHearts.transform = jackfHeartsTransform; 
    } 
       completion:^(BOOL finished) 
    {[UIView transitionWithView:_jackOfHearts duration:0.40f options:UIViewAnimationOptionTransitionFlipFromRight animations:^{ 
     _jackOfHearts.image = [UIImage imageNamed:@"112"]; 
    }completion:nil]; 
    [UIView animateWithDuration:0.30f 
         delay:0.0f 
         options:UIViewAnimationOptionCurveEaseOut 
        animations:^ 
    { 
     _aceOfHearts.center = CGPointMake(162, 196); 
     _aceOfHearts.transform = aceOfHeartsTransform; 
    } 
        completion: ... and so on. 

的赛格瑞代码看起来是这样的:

for (UIView *iv in src.view.subviews) { 
    if (iv.tag != 99999) { 
     [UIView animateWithDuration:0.5f animations:^{iv.center = CGPointMake(iv.center.x - 600, iv.center.y);}]; 
    } 
} 

回答

0

你可以添加一个全球BOOL说hasUserSkippedOn一旦用户按下移动上设置为是的,然后每次你点击一个完成块时,检查_hasUserSkipped是否仍然是,那么就不要再操作了。通常在块上它有一个默认的结束布尔,但我不太确定动画块是否有结束布尔。

+0

全局你的意思BOOL在某种单一的,我保持在整个应用程序活着? – 2013-03-02 01:02:56

+0

那么如果你只需要它在VC中,你可以添加它作为一个属性,并在该VC中的所有方法中使用它 – 2013-03-02 01:05:06

+0

你也可以使用@property(assign)BOOL varName not(nonatomic,strong) – 2013-03-02 01:23:30