2010-10-04 53 views
0

我開始啓動時,我的應用程序正在使用啓動屏幕,並使其進入睡眠狀態4秒。我需要的是如果用戶點擊在4秒之前的啓動畫面上,他應該導航到下一個屏幕。任何人都可以給我一些建議。如何使啓動屏幕睡眠4秒,直到用戶在iPhone上觸摸屏幕sdk

我的代碼我試過是:

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

任何人的幫助將非常感激。

謝謝大家, Monish。

回答

1

好了,你還沒有告訴我們任何代碼或告訴我們您的真正的問題是什麼,但在僞代碼,我會做這樣的事情:

- (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]; 
    } 
} 
+0

除了這一點,如果有什麼其他設置要在4秒鐘完成時完成,它必須異步完成,否則水龍頭將不會響應,直到其他設置完成。 – JeremyP 2010-10-04 15:41:34