-1

それぞれ異なるパスを持つ 3 つの CAShapeLayer がありますが、3 つのレイヤーには同じアニメーションが適用されます。つまり、次のようになります。

 [self animateToLineLayer:self.leftDottedLine_ withKey:@"leftLineAnimated"];

   - (void) animateToLineLayer:(CAShapeLayer *) line withKey:(NSString *) key
    {
        CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
        [pathAnimation setFromValue:[NSNumber numberWithFloat:0.0f]];
        [pathAnimation setToValue:[NSNumber numberWithFloat:1.0f]];
        [pathAnimation setDuration:10.0];
        [pathAnimation setDelegate:self];
        [pathAnimation setFillMode:kCAFillModeForwards];
        [line addAnimation:pathAnimation forKey:key];
    }

    then I try to find this animation back by doing:

    - (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)flag
    {
        if (animation == [self.leftDottedLine_ animationForKey:@"strokeEnd"]) {
            NSLog(@"DONE");
        }

        if (![self.leftDottedLine_ isNotNull]){
            NSLog(@"NIL");
        }

        NSLog(@"JUST DONE");
    }

しかし問題は、DONE! が印刷されないことです。どうしてこれなの?

4

1 に答える 1

0

animationDidStop デリゲートでアニメーションを識別する方法に関するヒントについては、こちらをご覧ください 。animationDidStop デリゲート内で CAAnimation を識別するには?

自分自身をデリゲートとして設定してもよろしいですか? また、おそらく == は機能しません。isEqualTo: または上記のリンクに記載されている文字列比較を試してください。

于 2012-10-05T21:53:18.290 に答える