2011-06-22 2 views
3

私はCABasicAnimationを作成していますが、問題はanimationDidStopデリゲートメソッドが呼び出されないことです。なぜ、誰かが知っていればうまくいけば分かりません。ここでCABasicAnimation - animationDidStopが呼び出されない

は私のアニメーションです。また、ここで

CABasicAnimation *theAnimation; 
theAnimation = [CABasicAnimation animationWithKeyPath: @"transform.translation.x"]; 
theAnimation.duration = 54; 
//theAnimation.repeatCount = 6; 
theAnimation.autoreverses = YES; 
theAnimation.removedOnCompletion = YES; 

theAnimation.fromValue = [NSNumber numberWithFloat: (self.myImageView.frame.size.height/5) + (self.view.frame.size.height - self.myImageView.center.x)]; 
theAnimation.toValue = [NSNumber numberWithFloat: 6.0 - (self.myImageView.frame.origin.y + self.myImageView.frame.size.height)]; 

//[self.myImageView.layer addAnimation:theAnimation forKey: @"animateLayer"]; 
[theAnimation setValue:@"Animation1" forKey:@"animateLayer"]; 
[[self.myImageView layer] addAnimation:theAnimation forKey:nil]; 

は私のanimationDidStop方法である:

- (void)animationDidStop:(CABasicAnimation *)theAnimation finished:(BOOL)flag { 

    NSString* value = [theAnimation valueForKey:@"animateLayer"]; 
    if ([value isEqualToString:@"Animation1"]) 
    { 
     [self themethod]; 
     return; 
    } 


    if ([value isEqualToString:@"Animation2"]) 
    { 
     [self themethod]; 
     return; 
    } 
} 

は、なぜこれが起こっている誰もが知っていますか?

答えて

9

animationDidStopを呼び出すには、代理人を設定する必要があります。

theAnimation.delegate = class (self) 
+0

'CAAnimation'の' delegate'が強いので、あなたはサイクルを維持避けるためにnil' 'にそれを設定する必要がある場合がありますことを__Beは承知!__ –

+0

おかげで、おそらくまだ実装されていない2011年に「強いです」 ... :) – elp

+0

私はそれを学び、それがインターネット上のどこにでも言及するのを見なかったので、これを見いだすのは他の人々のためでした。 –

関連する問題