带有tabBarController的PushViewContr

带有tabBarController的PushViewContr

本文介绍了带有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不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:50