开发者

NavigationBar not appearing with TTThumbsViewController in UITabBarController

开发者 https://www.devze.com 2023-03-24 05:53 出处:网络
I\'m trying to put a TTThumbsViewController inside a UITabBarController, but when I do, the TTThumbsViewController\'s NavigationBar doesn\'t show. There is just blank space where the NavigationBar sho

I'm trying to put a TTThumbsViewController inside a UITabBarController, but when I do, the TTThumbsViewController's NavigationBar doesn't show. There is just blank space where the NavigationBar should be. I've loaded just the TTThumbsViewController by itself, and the NavigationBar loads just fine. I'm sure I've just missed a setting, but I can't figure out what it is.

Here is what I'm doing to creat开发者_StackOverflow社区e the UITabBarController and the 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;
}


If you're loading the TTThumbsViewController from a UITabController, you need to create the UINavigationController yourself.

- (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

精彩评论

暂无评论...
验证码 换一张
取 消