3

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;
    }
}

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

4

1 に答える 1

9

call にデリゲートを設定する必要がありますanimationDidStop

theAnimation.delegate = class (self)
于 2011-07-01T12:46:41.837 に答える