Search code examples
iphoneuitableviewuitabbar

iPhone: change view when selevting a table cell which is in a tabbar


I have a UITabBar with 2 views. One view contains a UITable. When I am selecting a cell I want to navigate to another view.

I always did it with this code:

 if(self.damageController == nil)
    {

        DamageControllerOverview *viewTwo = [[DamageControllerOverview alloc] initWithNibName:@"DamageControllerOverview" bundle:[NSBundle mainBundle]];


        self.damageController = viewTwo;
        self.damageController.damageAccount = damageAccount;
        self.damageController.ma = ma;

        [self.navigationController setNavigationBarHidden:NO animated:NO];

        temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
        temporaryBarButtonItem.title = @"Back";

        self.navigationItem.backBarButtonItem = temporaryBarButtonItem;

        [viewTwo release];
    }

    [self.navigationController pushViewController:self.damageController animated:YES]; 

But since I have the table in the Tabbar it is not working anymore. Does anybody know why?

Best regards Melanie

*Edit: this is not my rootviewcontroller. I already have a navigationcontroller and don't want to create a new one in the tabbar


Solution

  • What i understand from your question is that

    1- you have a tabbar in the main window 2-then you have a navigationController in the tabbar.

    so you need to push your controller to the navigationController this way.

    [self.tabBarController.navigationController pushViewController:self.damageController animated:YES];
    

    instead of [self.navigationController pushViewController:self.damageController animated:YES];

    I hope it helps