2012-01-26 39 views
0

我有一個Web服務應用程序,它有阿爾金視圖。我想讓我的應用程序的登錄視圖在第一次應用程序加載(安裝)時到來,之後它必須始終以第二個視圖開始。我怎樣才能做到這一點?在this鏈接有一些解決方案,但我認爲這不是我要找的。由於我是一個網絡服務,意味着第二個視圖(我想推動所有)的內容是從服務器(我使用NSJSONSerialization類爲這項工作)如何讓我的應用程序總是以第二個視圖開始?

回答

2

我會做登錄視圖作爲模式只有在需要時才顯示。

編輯: 這是非常簡單的:(我假設你正在使用ARC)

在AppDelegate中:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: mySecondViewController]; 

if (![self isUserLoggedIn]) { 
    MyLogInViewController *logInViewController = [[MyLogInViewController alloc] init]; 
    [self presentModalViewController: MyLogInViewController animated: YES]; 
} 
[[self window] setRootViewController: [self navigationController]]; 

和logInViewController:

- (void)logInSuccessful { 
    [self dismissModalViewControllerAnimated: YES]; 
} 
+0

對不起,我有創建所有的應用程序,並剛剛意識到這種情況我現在需要改變一切嗎?或者,有沒有把我的登錄視圖變成「模型」? –

+0

對不起,我的意思是模態不是模型。這兩種觀點如何呈現? UINavigationController的? – dasdom

+0

這將是理想的,但這取決於您如何設置應用程序?它是一個基於導航的應用程序?基於TabBar? – Lance

相關問題