1

我正在尝试围绕我的 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;
4

1 回答 1

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;
于 2012-08-24T11:01:41.433 回答