2013-03-29 31 views
0

首先,我正在使用故事板進行導航。我已經到了一個地步,我正在一個菜單屏幕上顯示4個不同的視圖(僅使用導航控制器),我希望它檢查用戶是否已登錄,如果不是,我希望LoginViewController /視圖提出。我對客觀的c/xcode非常陌生,並且在尋找解決方案後,這就是我所想到的。我不知道如何將它與我的程序聯繫起來。這只是需要鏈接到我的按鈕,或者我完全與我現在在做什麼?檢查用戶登錄故事板前的場景登錄

if (self.appDelegate.userHasActiveLogin) { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController2"]; 
    [vc setModalPresentationStyle:UIModalPresentationFullScreen]; 

    [self presentModalViewController:vc animated:YES];} 
else { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginController"]; 
    [vc setModalPresentationStyle:UIModalPresentationFullScreen]; 

    [self presentModalViewController:vc animated:YES]; 
} 
+0

只是一個提示,如果你還沒有發現這一點,斯坦福在iTunes上的ios開發課程u:https://itunes.apple.com/us/course/coding-together-developing/id593208016 它真的速度瞭解ios開發的過程,講座非常優秀 – Andreas

+0

更新您在〜2小時前提出的原始問題,而不是創建一個新的問題。 http://stackoverflow.com/questions/15708904/verifying-login-before-loading-view-controller – rog

回答

1

你可以做的是在你的故事板中創建手動節點。

從菜單控制器(橙色符號)按住Ctrl鍵拖動到子控制器,選擇按下。點擊segue並在屬性檢查器中給它一個標識符。現在您可以檢查用戶是否已登錄,然後在菜單的VC中有條件地呼叫[self performSegueWithIdentifier:@"logged in segue" sender:self];

條件是,所有的風險投資家必須在同一個故事板,但我懷疑是這樣。