15

ページの下部にある例に従って、animationDidStop関数を呼び出しています。

http://www.informit.com/articles/article.aspx?p=1168314&seqNum=2

著者は次のように述べています。

アニメーションのデリゲートとして特別に設計されたオブジェクトがあり、ターゲット オブジェクトへの参照を保持し、animationDidStop: メッセージを受け入れ、それ自体を解放するだけです。

これは、すべきでないことを示唆しています:

[animation setDelegate:self];

私はアプリのプログラミングにかなり慣れていないので、誰かがこれを行う方法を概説できますか? または、説明されているリンクを送ってください。

4

3 に答える 3

38

埋め込む:

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag

あなたのデリゲートオブジェクトで。以下を実装することもできます。

- (void)animationDidStart:(CAAnimation *)theAnimation

アニメーションの開始時に電話を受ける。

詳細については、次のデリゲート セクションを参照してください: http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CAAnimation_class/Introduction/Introduction.html

于 2010-07-27T22:52:23.320 に答える
4

アニメーションの完了時にレイヤーの実際の値を toValue に設定する必要がある場合があります。CAGradientLayer の色をアニメーション化するなど、より複雑なアニメーションの場合、これは必須です。

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
  self.gradientLayer.colors = (NSArray *)((CABasicAnimation*)theAnimation).toValue;
}
于 2013-07-02T00:14:43.820 に答える
0

設定するだけ

[UIView setAnimationDelegate:self];

アニメーションの開始時または終了時に Animation デリゲート メソッドを呼び出しません。

この問題は、次の回避策のいずれかで解決できます。

1)実装セクションに追加

@implementation MyViewWithAnimations <UIApplicationDelegate>


2) アニメーションで begin-commit-block を追加

[UIView setAnimationWillStartSelector:@selector(animationDidStart:)];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];


3) Apple が提案することを行い、代わりにブロックベースのアニメーション方法を使用します。

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html

于 2012-08-08T14:53:27.270 に答える