【问题标题】:UITableViewController in UITabBarUITabBar 中的 UITableViewController
【发布时间】:2012-08-19 22:23:19
【问题描述】:

我正在尝试围绕我的 UITableView 控制器创建一个 UITabBarController。我正在使用这段代码。但问题是,当使用它时,导航栏会消失。我该如何解决这个问题?

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
StyledTableViewController *viewController1 = [[StyledTableViewController alloc] initWithNibName:@"StyledTableViewController" bundle:nil];

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;

【问题讨论】:

    标签: ios xcode uinavigationcontroller uitableview


    【解决方案1】:

    需要将 UINavigationController 添加到导航栏,并保持您的视图层次结构

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    StyledTableViewController *viewController1 = [[StyledTableViewController alloc] initWithNibName:@"StyledTableViewController" bundle:nil];
     UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:viewController1];
    
    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = @[navController];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;
    

    【讨论】:

    • 啊,我看到了简单的解决方案。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多