Hi guys I am working on an application.Where there is a home screen with 5 buttons.On the click of every button i want to open the screen with tabbar with 5 view controllers.I mean 开发者_如何转开发when you click on the button the tabbar is opened.And there are back button on the tab bar view as well .On clicking the back button i want to pop back to the home screen and vice versa. How to do that guys.Any tutorial ,links,sample code would be appreciated.
Thanks a lot to all
Tabbar controller in a navigation stack is complicated. Since each tab controller can have also navigation controller itself.
Have a WindowManager
class. It should own both
- FirstViewController
and
- TabbarController
All components and the UITabbarControllers themselves should be instantiated in the WindowManager class.
Its init
may have code like this, make similar for two tabbarcontrollers.
self.tabBarController = [[UITabBarController alloc] init];
self.controllers = [[NSMutableArray alloc] init];
// initialize the view controllers and navigation controllers for the tab bar
self.friendsVC = [[FriendsVC alloc] initWithNibName:@"FriendsView" bundle:nil];
UINavigationController *friendsNVC = [[UINavigationController alloc] initWithRootViewController: friendsVC];
friendsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:friendsNVC];
[friendsNVC release];
self.paymentsVC = [[PaymentsVC alloc] initWithNibName:@"PaymentsView" bundle:nil];
UINavigationController *paymentsNVC = [[UINavigationController alloc] initWithRootViewController: paymentsVC];
paymentsNVC.navigationBar.barStyle = UIBarStyleBlack;
[controllers addObject:paymentsNVC];
[paymentsNVC release];
tabBarController.viewControllers = controllers;
tabBarController.selectedIndex = 0;
tabBarController.delegate = self;
self.view = tabBarController.view;
In the WindowManager
, you can have two methods like,
[WindowManager showViewController] and
[WindowManager showTabbarController].
- showViewController {
//Initiate View controller and use [self.window addSubView:vc.view];
}
- showTabbarController {
// initiate the tabbar manager
}
You can have a "back" button on top of your first tabbar controller left side, to call the
[WindowManager showViewController];
精彩评论