ViewDeck / ViewDeck

An implementation of the sliding menu found in various iOS apps.
5.32k stars 964 forks source link

UITabBarController not persistent #68

Closed argentini closed 12 years ago

argentini commented 12 years ago

I use the code below to create a tab bar with three view controllers (three tabs), each with a navigation controller. The various view controllers (beginning with "Q") are UITableViewControllers. It works pretty well.

The problem is that the tab bar vanishes when I advance from a table view to the various detail views using "pushViewController". Is there a way (or a special way) I can push a new view controller onto the screen and maintain the tab bar?

QViewController *qController = [[QViewController alloc] initWithNibName:@"QViewController" bundle:nil];
QAuthorsViewController *qAuthorsController = [[QAuthorsViewController alloc] initWithNibName:@"QAuthorsViewController" bundle:nil];
QFavoritesViewController *qFavoritesController = [[QFavoritesViewController alloc] initWithNibName:@"QFavoritesViewController" bundle:nil];

qController.tabBarItem.title = Q_BROWSE_TABBAR_TITLE;
qController.tabBarItem.image = [UIImage imageNamed:@"TabBar-Q"];

qAuthorsController.tabBarItem.title = Q_PEOPLE_TABBAR_TITLE;
qAuthorsController.tabBarItem.image = [UIImage imageNamed:@"TabBar-People"];

qFavoritesController.tabBarItem.title = Q_FAVORITES_TABBAR_TITLE;
qFavoritesController.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"NavController-Menu-Button"] title:@"" target:self.viewDeckController action:@selector(toggleLeftView)];

self.tabBarController.navigationItem.title = qController.title;
self.tabBarController.viewControllers = [NSArray arrayWithObjects:qController, qAuthorsController, qFavoritesController, nil];

[self.viewDeckController closeLeftViewBouncing:^(IIViewDeckController *controller) {

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tabBarController];
    [navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"Q-Bottom-Bar"] forBarMetrics:UIBarMetricsDefault];
    self.viewDeckController.centerController = navigationController;
    [NSThread sleepForTimeInterval:0.10];

}];
argentini commented 12 years ago

Ugh. Stupid me. I was wrapping one navigation controller inside one tab bar. Each view needs its own navigation controller. Non-issue happily closed.