5

タイトルが言ったように、それは非常に奇妙ですが、同意しますか?

だから、誰かがあなたのコードを見つけたら

imageView.backgroundColor = [UIColor greenColor]; 

また

imageView.image = [UIImage imageName:@"angryBird"];" 

動作していません。imageView がアニメーション化されている場合、またはアニメーションが削除されているかどうかに注意してください。

----------以下の回答---------------</p>

画像を設定する前にアニメーションを停止し、アニメーション UIImageView の背景を変更します。

UIImageView* imageView = [UIImageView alloc] init];
//......do sth. like setFrame ...
imageView.images = [NSArray arrayWithObjects....]; // set the animation images array 
imageView.animationDuration = 1.0;
[imageView startAnimating];
//......do sth.
[imageView stopAnimating];        // **** do not forget this!!!!! ****
imageView.backgroundColor = [UIColor greenColor];
imageView.image = [UIImage imageName:@"angryBird"];

Selector: withObject: afterDey:1.0s を実行する場合、セレクター メソッドでも、アニメーションを停止してから、setImage または背景色を変更する必要があります。

4

4 に答える 4

5

アニメーションが完了したら、背景色を変更して画像を変更してみてください。それは単にあなたのために働くでしょう。

于 2013-05-31T12:19:31.470 に答える
1

これを試して:

[UIView animateWithDuration:1.0 animations:^(){} completion:^(BOOL finished){}];
于 2013-05-31T12:16:47.090 に答える
0

やってみる、ブロックを使ったアニメーション

[UIView animateWithDuration:1.0 animations:^{
    }
    completion:^(BOOL finished)
    {
        [imageView setImage:[UIImage imageNamed:@"YOUR_IMAGE_NAME"]];
        [imageView setBackgroundColor:[UIColor greenColor]];


    }];

注:そうではありimageNamed:ません。これがimageName:どのようにコンパイルされるのかわかりません

于 2013-05-31T12:44:53.293 に答える
0

このコードを試して、この方法で performSelector:withObject:afterDelay::

    [self performSelector:@selector(animationDidFinish:) withObject:nil
         afterDelay:instructions.animationDuration];

または、dispatch_after を使用します。

    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, instructions.animationDuration * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
         [self animationDidFinish];
    });

お役に立てば幸いです

于 2013-05-31T12:09:43.357 に答える