带有tabBarController的PushViewController不起作用

编程入门 行业动态 更新时间:2024-10-26 22:16:10
本文介绍了带有tabBarController的PushViewController不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个tabBar应用程序.选项卡中的一个具有rootviewcontroller,它创建一个UITableView并将其添加到子视图中.当用户单击UITableView中的单元格时,我想推送一个新的rootviewcontroller,但无法使其正常工作.

I have a tabBar application. One of the tabs has a rootviewcontroller that creates a UITableView and adds it to the subview. When a user clicks a cell in the UITableView I want to push a new rootviewcontroller but I cant get it to work.

在我的appDelegate中:

In my appDelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Create the window self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; //Create the UIViewCOntrollers for each tab _viewController1 = [[[LocavoreRetroFirstViewController alloc] initWithNibName:@"LocavoreRetroFirstViewController" bundle:nil] autorelease]; _viewController2 = [[[LocavoreRetroSecondViewController alloc] initWithNibName:@"LocavoreRetroSecondViewController" bundle:nil] autorelease]; UIViewController *viewController3 = [[[LocavoreRetroThirdViewController alloc] initWithNibName:@"LocavoreRetroThirdViewController" bundle:nil] autorelease]; _viewController4 = [[[LocavoreRetroFourthViewController alloc] initWithNibName:@"LocavoreRetroFourthViewController" bundle:nil] autorelease]; UIViewController *viewController5 = [[[LocavoreRetroFifthViewController alloc] initWithNibName:@"LocavoreRetroFifthViewController" bundle:nil] autorelease]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_viewController1]; //[_viewController1 release]; NSArray* controllers = [NSArray arrayWithObjects:navigationController, _viewController2, viewController3, _viewController4, viewController5, nil]; //Create the tab controller _tabBarController = [[[UITabBarController alloc] init] autorelease]; [_tabBarController setViewControllers:controllers]; //Initialize the tab controller with the views // _tabBarController.viewControllers = @[_viewController1, _viewController2, // viewController3, _viewController4, viewController5]; //Set the window to the tabcontroller view and make it visible _window.rootViewController = _tabBarController; _tabBarController.delegate=self; [_window makeKeyAndVisible]; return YES; }

在我的子视图中,didSelectRowAtIndexPath方法:

In my subview didSelectRowAtIndexPath method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { RecipePageController *recipePageController = [[RecipePageController alloc] initWithNibName:@"RecipePageController" bundle:nil]; [self.navigationController pushViewController:recipePageController animated:YES]; [recipePageController release]; }

推荐答案

对于每个标签,您需要创建一个单独的导航控制器

For each tab you need to create a separate navigation controller

更多推荐

带有tabBarController的PushViewController不起作用

本文发布于:2023-11-24 11:12:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624969.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   tabBarController   PushViewController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!