I am creating an app as follows- when the app starts a tableview is displayed. I am creating this programmatically. On selecting a particular row i do a presentModalViewController to display my tabbar class which i created programmatically.
ViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ShowOptionInTab *showTabbar = [[ShowOptionInTab alloc] initWithNibName:@"ShowOptionInTab" bundle:nil];
UINavigationController *mynavController = [[UINavigationController alloc] initWithRootViewController:showTabbar];
[self presentModalViewController:mynavController animated:YES];
[showTabbar release];
}
ShowOptionsInTab.m class
@implementation ShowOptionInTab
-(void)loadView {
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
self.view = contentView;
[contentView release];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissTabbar:)];
self.navigationItem.rightBarButtonItem=doneButton;
UITabBarController *tabbarController = [[UITabBarController alloc] init];
tabbarController.view.frame = CGRectMake(0, 0, 320, 460);
BuyerViewController *buyerController = [[BuyerViewController alloc] init ];
buyerController.navigationItem.title=@"Buyer";
buyerController.title=@"Buyer";
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
SellerViewController *sellerController = [[SellerViewController alloc] init];
sellerController.navigationItem.title=@"Seller";
sellerController.title=@"Seller";
LenderViewController *lenderController = [[LenderViewController alloc] init];
lenderController.navigationItem.title=@"Lender";
lenderController.title=@"Lender";
tabbarController.viewControllers = [NSArray arrayWithObjects:buyerController,sellerController,lenderController, nil];
[self.view addSubview:tabbarController.view];
[sellerController release];
[buyerController release];
[lenderController release];
}
-(void)dismissTabbar:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
My ShowOptionsInTab class is a subclass of UIViewController
I have 3 tabs Buyer, Lender and Seller. Each tab has buttons which navigate to a different UIViewController page. Suppose i have ‘ButtonA’ and ‘ButtonB’ in my Buyer tab class. The problem i am facing is that i cannot navigate on the buttons present in Buyers tabs(or any other tabs). It doesnt push to the next class which ‘ButtonA’ should load. It also has a “Done” button on navigation bar which will dismiss the modal view and display my table view.
What am i doing wrong? if i add these tabs to localNavigationController object which i create in my ShowOptionsInTab.m class i get 2 Navigations Bars.
I got the solution. I made 3 local navigationController object and added each of my tabbar class as its rootviewController.