0

在用戶可以使用我的應用程序之前必須登錄。我的想法是,在應用程序啓動後,登錄視圖以模態顯示。未啓動應用程序後的模態視圖不出現

在iOS 5之前,我已經使用了.xib文件。現在我想將視圖轉換爲故事板以便概覽並更好地使用新功能。

該應用程序與分割視圖控制器一起使用。問題在於登錄視圖已加載,但從未出現。

我在應用程序委託中嘗試了它,併爲splitviewcontroller創建了一個類,並嘗試將其加載到viewDidLoad中。

代碼:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    //load and push login 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"]; 

    NSLog(@"login push: %@", loginViewController); 
    [self presentModalViewController:loginViewController animated:YES]; 
    NSLog(@"done push"); 
} 

登錄:

2012-01-13 10:18:08.217 App[1101:707] login push: <LoginViewController: 0x472fe0> 
2012-01-13 10:18:08.330 App[1101:707] done push 

我試圖將其加載到根目錄或詳細視圖,它的工作原理,但其不正確的地方和Xcode中給出了消息:

2012-01-13 10:18:08.807 App[1101:707] Unbalanced calls to begin/end appearance transitions for <MainSplitViewController: 0x464bc0>. 

我的第一個想法是先從登錄視圖開始,登錄後再按下splitview co ntroller。但是我發現splitview控制器必須是根視圖。

回答

3

在viewDidLoad中推另一個ViewController是很早的。也許當前視圖控制器呈現動畫,並嘗試提出了另一個視圖控制器動畫...

你應該嘗試移動你的LoginController到viewDidAppear的顯示...

+0

非常感謝。我沒有想到我自己......有時候解決方法很簡單。再次感謝! – Justin 2012-01-13 09:48:48

相關問題