我正在创建一个应用程序,如下所示 - 当应用程序启动时,会显示一个tableview。我是以编程方式创建的。在选择特定行时,我执行presentModalViewController以显示我以编程方式创建的tabbar类。
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];
}
我的ShowOptionsInTab类是UIViewController的子类
我有3个标签买家,贷方和卖家。每个选项卡都有按钮,可以导航到不同的UIViewController页面。假设我有按钮A'和' ButtonB'在我的买方标签类中。我面临的问题是我无法导航买家标签(或任何其他标签)中的按钮。它并没有推向下一个班级,而按钮A'应该加载。它还有一个"完成"导航栏上的按钮将关闭模态视图并显示我的表格视图。
我做错了什么?如果我将这些选项卡添加到我在ShowOptionsInTab.m类中创建的localNavigationController对象,我将获得2个导航栏。
答案 0 :(得分:0)
我得到了解决方案。我创建了3个本地navigationController对象,并将我的每个tabbar类添加为rootviewController。