tags:

views:

25

answers:

1

Hi Guy's,

I am using splash screen for my application when it starts begining and I made it to sleep for 4 seconds.My need is if user taps on the splash screen before the 4 seconds he should navigate to the next screen.Can any one suggest me with some ideas.

My code I tried was:

- (void)applicationDidFinishLaunching:(UIApplication *)application
{    

// Override point for customization after application launch



[self createEditableCopyOfDatabaseIfNeeded];
[self initializeDataStructures];

mainController = [[FavoritesViewController alloc] init] ;
 navController = [[UINavigationController alloc] initWithRootViewController:mainController];
navController.navigationBar.barStyle = UIBarStyleBlack;
[window addSubview:navController.view];
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:@"default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
sleep(4);
// Do your time consuming setup
[splashView removeFromSuperview];
[splashView release];
 [window makeKeyAndVisible];
}

Anyone's help will be much appreciated.

Thank's all, Monish.

+1  A: 

Well, you haven't shown us any code or told us what your real problem is, but in pseudo-code I would do something like this:

- (void) start {
  [self showSplashScreen];
  fourSecondsRunning = YES;
  // In four seconds, call stop.
  [self performSelector:@selector(stop) withObject:nil afterDelay:4.0];
}

- (void) stop {
  // View wasn't tapped during the last 4 seconds. Do something.
  fourSecondsRunning = NO;
  [self hideSplashScreen];
  [self doSomething];
}

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  if (fourSecondsRunning) {
    fourSecondsRunning = NO;
    // Touched within the four seconds. Make sure "stop" is not called.
    [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
    [self hideSplashScreen];
    [self goToNextScreen];
  }
}
DarkDust
As well as this, if there is anything other setup to be done while the 4 seconds is going, it must be done asynchronously, or the tap won't be responded to until the other set up is complete.
JeremyP