0

再生ボタンを押すと、6つの画像ビューが押された画像でいっぱいになります。表示1、1秒待機、view2、1秒待機などです。

どのコードに追加する必要がありますか:

[imageview7 setImage:imageview1HG.image];
      [imageview8 setImage:imageview2HG.image];
        [imageview9 setImage:imageview3HG.image];
        [imageview10 setImage:imageview4HG.image];
        [imageview11 setImage:imageview5HG.image];
        [imageview12 setImage:imageview6HG.image];

私はこれを試しました:しかし、それは機能しません:

[self performSelector:@selector(GameViewController)  withObject:nil afterDelay:1]; 

誰かがさようなら感謝を知っていることを願っています

私のコードをもっと説明する編集

-(IBAction)play {

 [self performSelector:@selector(delay) withObject:nil afterDelay:5.0];

play.enabled=NO;

UIImage *img = [UIImage imageNamed:@""];

if (imageview7.image == nil) {

    if([textview.text isEqualToString:labelsText.text]){

        -(void)delay {
        [imageview7 setImage:imageview1HG.image];
        [imageview8 setImage:imageview2HG.image];
        [imageview9 setImage:imageview3HG.image];
        [imageview10 setImage:imageview4HG.image];
        [imageview11 setImage:imageview5HG.image];
            [imageview12 setImage:imageview6HG.image];}
    }
    else {

        -(void)delay {
    [imageview7 setImage:imageview1H.image];
    [imageview8 setImage:imageview2H.image];
    [imageview9 setImage:imageview3H.image];
    [imageview10 setImage:imageview4H.image];
    [imageview11 setImage:imageview5H.image];
            [imageview12 setImage:imageview6H.image];}
4

2 に答える 2

2

UIImageView の setImage を遅れて次々に設定したいと思います。そのためのコードは次のとおりです。

意味

@interface ViewController : UIViewController
{  
    NSMutableArray * imageViews;
    NSMutableArray * images;
    int count;
    NSTimer * timer1;
}
-(void)setImageForView:(UIImageView *)imageView withImage:(UIImage *)image;
-(void)update;
-(IBAction)setImageOnViewOneAfterOther;
@end

意味

-(void)setImageForView:(UIImageView *)imageView withImage:(UIImage *)image{

    [imageView setImage:image];
}
-(void)update{

    if (count < [imageViews count]) {
        [self setImageForView:[imageViews objectAtIndex:count] withImage:[images objectAtIndex:count]];
        count ++;
    }else{
        [timer1 invalidate];
    }

}
-(IBAction)setImageOnViewOneAfterOther{
    count = 0;
    imageViews = [[NSMutableArray alloc] initWithObjects:img1v,img2v,img3v,img4v,img5v,img6v, nil]; // Set of all UIImageViews 
    images = [[NSMutableArray alloc] initWithObjects:img1,img2,img3,img4,img5,img6, nil];//Set of all UIImage's where img = [UIImage imageNamed:@"someImage1.png"];
    timer1 = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(update) userInfo:nil repeats:YES];
}
于 2012-04-22T19:57:23.930 に答える
0

なぜそれをアニメ化しないのですか?

UIImageView* animatedImageView = [[UIImageView alloc]init];
animatedImageView.animationImages = [NSArray arrayWithObjects:    
                                 [UIImage imageNamed:@"1.gif"],
                                 [UIImage imageNamed:@"2.gif"],
                                 [UIImage imageNamed:@"3.gif"],
                                 [UIImage imageNamed:@"4.gif"], nil]; //etc
animatedImageView.animationDuration = float([animatedImageView.animationImages count]);
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];
于 2012-04-22T19:29:13.610 に答える