UITabBar中的UITableViewController

时间:2012-08-24 10:49:36

标签: ios xcode uinavigationcontroller uitableview

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

1 个答案:

答案 0 :(得分: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;