Create UINavigationController in UITableViewController inside UITabBarController

我只是一个虾纸丫 提交于 2019-12-09 08:35:37

Just watch this tutorial. http://www.youtube.com/watch?v=LBnPfAtswgw

First You Will need to reset your hierarchy to something like this:

UITabBarController (BASE)
  |
  |___ UINavigationController
      |
      |___ UITableViewController (PRODUCTS)
        |
        |___ UIViewController (PRODUCT DETAILS)

You need to add a UINavigationController in the TabBarController, then you will use it to push the Product Detail.

to add a UINavigation on TabBarController:

UITabBarController *tabBarController = [[UITabBarController alloc] init];

UINavigationController *tableNavController_1 = [[[UINavigationController alloc] initWithRootViewController:YourProductViewController_1] autorelease];
UINavigationController *table2NavController_2 = [[[UINavigationController alloc] initWithRootViewController:YourProductViewController_2] autorelease];

tabBarController.viewControllers = [NSArray arrayWithObjects:tableNavController_1, table2NavController_2, nil];

//then add the controller to view like,
// this:
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];

//or this:
[self.view addSubview:tabBarController.view];

I recommend you to create a new UITableViewController for each ProductViewController and then use the delegate method: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath for pushing the detail view:

DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"Nib name" bundle:nil];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES]
[detailViewController release];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!