2011-11-28 31 views
0

UITabbar +導航應用程序。我的模式controllerNav沒有出現在屏幕上。哪裏不對?我的模態視圖控制器沒有出現在屏幕上。 UITabbar +導航應用程序

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window.rootViewController = self.tabBarController; 

    if (isLoginScreenNeeded) 
    {  
    LoginModalViewController *controller = [[[LoginModalViewController alloc] initWithNibName:@"LoginModal" bundle:[NSBundle mainBundle]] autorelease]; 

    UINavigationController *controllerNav = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease]; 
    [self.window.rootViewController presentModalViewController:controllerNav animated:NO]; 
    } 

    [self.window makeKeyAndVisible]; 
    return YES; 
} 

編輯:@Zoleas,我更新了我的代碼。如果我將刪除[self.window makeKeyAndVisible]; - 有用。但我不明白爲什麼我需要刪除self.window makeKeyAndVisible];

回答

1

剛剛從行中刪除parentViewController[self.window.rootViewController.parentViewController presentModalViewController:controllerNav animated:NO];

UITabBarControllerrootViewController所以它可能沒有parentViewController

+0

我刪除了parentViewController,但它沒有幫助我。 – Voloda2

+0

你確定所有的控制器都不是零嗎?在嘗試呈現你的modalViewController之前,你能記錄self.tabBarController,controller和controllerNav嗎? – Zoleas

0

映射您main.xib文件查看到rootViewcontrollers視圖..然後它會工作

+0

我更新了我的代碼。 isLoginScreenNeeded = YES時,我需要顯示modalVC; – Voloda2

0

使用下面的代碼映射

[map from:kAppViewController toModalViewController:[controller class]]; 
+0

地圖是什麼意思? – Voloda2

+0

我們使用Three20庫\t TTNavigator * navigator = [TTNavigator navigator]; \t \t navigator.persistenceMode = TTNavigatorPersistenceModeTop; \t \t TTURLMap * map = navigator.URLMap; –

+0

我不想使用Three20 – Voloda2

0

我發現makeKeyAndVisible從父級刪除了模態視圖,因此刪除行[self.window makeKeyAndVisible]; 或者您可以將其移動到頂部。

相關問題