views:

92

answers:

1

Hi there,

I need some help to find a View inside a hierarchy.

Here is how I build up the View stack.

Inside my first UITableViewController I push an UIViewController that contains an UITabBarController:

[[self navigationController] pushViewController:itemVC animated:YES];

Inside the UITabBarController I add an UITableViewController:

 ISSTableViewController *graphics = (ISSTableViewController *)[tabBarController.viewControllers objectAtIndex:3];

Inside the didSelectRowAtIndexPath I present a Modal View Controller using a UINavigationController:

 GraficoViewController *graph = [[GraficoViewController alloc] initWithNibName:@"GraficoViewController" bundle:nil];
  UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:graph];
  [self presentModalViewController:navigationController animated:YES];    
  [navigationController release];

Now the (BIG) question is: I have to hide the NagivationBar of my first UITableViewController inside my last view. I tried with this:

 [[[[[self parentViewController] parentViewController] parentViewController] navigationController] setNavigationBarHidden:YES];

but it doesn't work. Can someone tell me how I can find my ancestor View??? Thanks.

+1  A: 

Store pointer (as property) to your UINavigationController in application delegate or custom singleton object. Then you can access your navigation from any place.

Skie
I thought about that but I'm looking for a cleaner solution.
Oscar Peli
This is good solution because if you will change controllers hierarchy it would be work without changes.
Skie