0

I hit the play button 6 image views will be filled with the pressed images, I want it to view 1, wait 1 second,view2, wait one second etc.

which code should I be adding to:

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

I tried this: but it doesn't work:

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

hope someone knows bye thanks

EDIT explaining my code more

-(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];}
2
  • I'm guessing that -[YourObject GameViewController] isn't a valid method, explaining why your second code doesn't work. Commented Apr 22, 2012 at 18:56
  • sounds like nstimer is the solution you want [how to use nstimer][1] [1]: stackoverflow.com/questions/1449035/how-do-i-use-nstimer Commented Apr 22, 2012 at 19:08

2 Answers 2

2

I guess you want to setImage on UIImageView one after the other after a delay.Here is the code for it.

Definition

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

Definition

-(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];
}
Sign up to request clarification or add additional context in comments.

2 Comments

I've givin more info on my code can you have another look at it?
Then I have to change my entire code right because I have it like in my post (edited part)
0

Why not animate it?

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];

1 Comment

I gave more info on my code can you have a look why it is not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.