2012-02-22 52 views
1

我一直在尋找一些代碼,它會顯示一個登錄模式窗口之前加載其他視圖。登錄模式視圖不顯示在分割視圖

我創建了一個登錄筆尖,並在在applicationDidFinishLaunching的appdelegate我用這個代碼:

[window addSubview:splitViewController.view]; 
    IntroView *introViewController=[[[IntroView alloc] initWithNibName:@"IntroView" bundle:nil]autorelease]; 
    [introViewController setModalPresentationStyle:UIModalPresentationFullScreen] ; 
    [self.splitViewController presentModalViewController:introViewController animated:NO]; 
    [window makeKeyAndVisible]; 
... 

運行此,模態窗口不顯示,但是當我的NSLog它,它被加載。 任何想法爲什麼它沒有顯示?

回答

0

如果沒有活動會話(在覈心數據實體中定義),我的應用程序以分割視圖開始並打開模態登錄窗口。
將viewDidAppear方法添加到您的初始詳細視圖控制器。
爲新的登錄視圖控制器創建一個模態段。
請在登錄視圖中登錄內容,然後用「[self dismissModalViewControllerAnimated:YES]」將其解除;「

- (void)viewDidAppear:(BOOL)animated<br> 

{ 
[super viewDidAppear:animated]; 

    // Check if a existing session is open, if not the login screen will appear. 
    // When user logs on an open session record is added to the table. Closed on user logout. 

    userProfile = [LogonSessionManager getCurrentPtuser:managedObjectContext]; 
    if(userProfile == nil){ 
    [self performSegueWithIdentifier:@"login" sender:self]; 
    } else { 
     // We have a user - do user config display stuff 
    }  
} 
0

@greentor:你的回答不完全正確。正確的模態segue應該來自主SplitView。這意味着你必須調用你的DetailViewController#viewDidAppear:

[self.splitViewController performSegueWithIdentifier:@"login" sender:self.splitViewController]; 
[self.splitViewController performSegueWithIdentifier:@"login" sender:self.splitViewController]; 
+0

所以如何在成功登錄後關閉loginviewcontroller? – gdubs 2013-02-12 05:34:36