1

我試圖把一個TTThumbsViewController裏面的UITabBarController,但是當我這樣做時,TTThumbsViewController的NavigationBar不顯示。 NavigationBar應該只有空白區域。我已經自己加載了TTThumbsViewController,並且NavigationBar加載得很好。我確定我剛剛錯過了一個設置,但我無法弄清楚它是什麼。NavigationBar不顯示TTithumbsViewController在UITabBarController

下面是我在做什麼創造的UITabBarController和TTThumbsViewController:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.tabBarController = [[UITabBarController alloc] init]; 
    ThumbsViewController *thumbsViewController = [[ThumbsViewController alloc] init]; 
    UITabBarItem *thumbsTabBarItem = [[UITabBarItem alloc] initWithTitle:@"Thumbs" image:[UIImage imageNamed:@"icon.png"] tag:Thumbs]; 
    thumbsViewController.tabBarItem = thumbsTabBarItem; 
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:thumbsViewController, nil]; 
    self.window.rootViewController = self.tabBarController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

回答

2

如果你從一個UITabController加載TTThumbsViewController,你需要創建的UINavigationController自己。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.tabBarController = [[UITabBarController alloc] init]; 
    ThumbsViewController *thumbsViewController = [[ThumbsViewController alloc] init]; 
    UITabBarItem *thumbsTabBarItem = [[UITabBarItem alloc] initWithTitle:@"Thumbs" image:[UIImage imageNamed:@"icon.png"] tag:Thumbs]; 
    thumbsViewController.tabBarItem = thumbsTabBarItem; 

    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:ThumbsViewController] autorelease]; 

    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController, nil]; 
    self.window.rootViewController = self.tabBarController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 
+0

我接線,並導航欄出現,但現在TabBar沒有顯示。 – baleful

+0

嗯。理想情況下,您應該使用TTNavigator加載TTUITabController,例如在TTNavigatorDemo示例應用程序 – aporat

+0

必須在我的ThumbsViewController中將hidesBottomBarWhenPressed設置爲NO,但您的解決方案解決了我的問題。謝謝。 – baleful

相關問題