【问题标题】:NavigationBar not appearing with TTThumbsViewController in UITabBarController在 UITabBarController 中,导航栏没有与 TTThumbsViewController 一起出现
【发布时间】:2011-08-02 04:15:07
【问题描述】:

我正在尝试将 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;
}

【问题讨论】:

    标签: iphone uitabbarcontroller three20 ttthumbsviewcontroller


    【解决方案1】:

    如果您从 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;
    }
    

    【讨论】:

    • 我把它连线了,导航栏出现了,但现在 TabBar 没有显示。
    • 嗯。理想情况下,您应该使用 TTNavigator 加载 TTUITabController,例如在 TTNavigatorDemo 示例应用程序中
    • 还必须在我的 ThumbsViewController 中将 hidesBottomBarWhenPushed 设置为 NO,但您的解决方案解决了我的问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2016-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多