NavigationBar不会出现在UITabBarController中的TTThumbsViewController中

时间:2011-08-02 04:15:08

标签: iphone uitabbarcontroller three20 ttthumbsviewcontroller

我正在尝试将TTThumbsViewController放在UITabBarController中,但是当我这样做时,TTThumbsViewController的NavigationBar不显示。 NavigationBar应该只有空白区域。我自己只加载了TTThumbsViewController,而NavigationBar加载得很好。我确定我错过了一个设置,但我无法弄清楚它是什么。

以下是我正在创建的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;
}

1 个答案:

答案 0 :(得分:2)

如果你从UITabbarController加载Thumbs ViewController,你需要自己创建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;
}