1

私はUIImageViewimgView と呼ばれるものを持っています。ここには、次のような画像の配列があります。

  imageArray objects: [UIImage imageNamed:@"test4.png"],
                    [UIImage imageNamed:@"test5.png"],
                    [UIImage imageNamed:@"test6.png"],
                    [UIImage imageNamed:@"test7.png"],
                    nil];

次に、imgViewアニメーションに配列画像を追加しました

imgView.animationImages = imageArray;
imgView.animationRepeatCount = 0;
imgView.animationDuration = 2.0f;

[imgView startAnimating]; 

ここでは、すべてが正常に機能します。アニメーションの 1 サイクルが終了してから 5 秒遅らせる必要があります。どうすればこれを行うことができますか、私は使用しました

 [self performSelector:@select...

動作しません。何かアイデアを教えてください。

4

2 に答える 2

0

これを試して:

-(void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];

    [self animationMethod];  //where you start the animation
}

-(void) animationMethod {
    NSMutableArray *imageArray  = [[NSMutableArray alloc] initWithObjects:[UIImage imageNamed:@"btnVideoEffectSample1.png"], [UIImage imageNamed:@"btnVideoEffectSample2.png"], [UIImage imageNamed:@"btnVideoEffectSample3.png"], [UIImage imageNamed:@"btnVideoEffectSample4.png"], nil];
    imgProfilePicture.animationImages = imageArray;
    imgProfilePicture.animationRepeatCount = 0;
    imgProfilePicture.animationDuration = 2.0f;
    [imgProfilePicture startAnimating];
    [imageArray release];

    double delayToStopAnimation = 2.0;
    dispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, delayToStopAnimation * NSEC_PER_SEC);
    dispatch_after(startTime, dispatch_get_main_queue(), ^(void){
        [imgProfilePicture stopAnimating];

        double delayToRestartAnimation = 5.0;
        dispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, delayToRestartAnimation * NSEC_PER_SEC);
        dispatch_after(startTime, dispatch_get_main_queue(), ^(void){
        [self animationMethod];
        });
    });
}
于 2013-05-14T13:17:34.643 に答える
0

1 サイクルが完了したら、使用[imgView stopAnimating];し、必要に応じてスーパー ビューから削除します。このNSTimer後、7 秒後に呼び出される を配置し、アニメーションを再開します。これは、イメージ サイクル全体に 2 秒かかり、アニメーションを完了するのに合計時間が 2 秒かかるためです。この後、5 秒の休憩が必要な場合、合計時間は 7 秒になります。メソッドは、次のように呼び出す NStimer メソッドからアニメーションを開始します。

[NSTimer timerWithTimeInterval:7.0 target:self selector:@selector(startAnimation) userInfo:nil repeats:YES];

問題がある場合は、こちらのリンクを見つけてください

お役に立てれば。

于 2013-05-14T13:41:26.207 に答える