简体   繁体   中英

Display one Image then second Image after User Preses “Start” on iPhone

I am trying to get two images to display, one right after the other; after the user pushes “START”. The first image will display for 3 seconds and then the second image will display right afterward. Each image is set to pause for 3 seconds. It complies okay for (3G 4.2.1) simulator runs on simulator when either of the images is commented out, but hangs on the first image when coded as follows:

//this method gets called when the start button is pressed
-(IBAction) start {

    [self.navigationController pushViewController:self.**halfSplashController** animated:YES];

    [self.navigationController pushViewController:self.**halfSplash2Controller** animated:YES];
}

Is there a command I need to insert between the two or should it display the first image and then go on to the second image as I envision?

I think you should use NSTimer for the delay of 3 seconds. Try Following Code

-(IBAction) start 
{
  [self.navigationController pushViewController:self.**halfSplashController** animated:YES];

  [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(theActionMethod) userInfo:nil repeats:NO];  
  [currentTimer fire];
}


- (void)theActionMethod 
{
   [self.navigationController pushViewController:self.**halfSplash2Controller** animated:YES];
}

It will change the image after 3 seconds.If you want to repeatedly change the image then change repeats to YES in NSTimer initialization.And also change the code in theActionMethod() function.

您也可以使用[self performSelector:afterDelay]方法,它应该可以按照您想要的方式工作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM