views:

11

answers:

1

Can anyone tell me if this is possible?

I have a setup a UITableViewController which consists of a number of cells, if you select one of these cells you are taken to a new viewController using pushViewController (see below)

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSUInteger row = [indexPath row];
    NSLog(@"CELL__: You tapped the row ... %@", [list objectAtIndex:row]);
    TestController *testController = [[TestController alloc] init];
    [[self navigationController] pushViewController:testController animated:YES];
    [testController release];
}

If in the implementation for "TestController" I would like to refer back to [self navigationController] (or maybe to add yet another view) is there any way to do that. My problem is that I need to access [self navigationController] to push further views and I don't know how to do that from the bottom controller?

Does that make sense?

Gary

+1  A: 

From within TestController you reference the same UINavigationController via [self navigationController] as well.

EDIT to elaborate after comment:

The navigationController property is a property of UIViewController. If the controller is contained within a UINavigationController then it's own navigationController property will be a reference to that container UINavigationController. The same applies for tabBarController and splitViewController.

imaginaryboy
Ah I see how it works... its a property of the UINavigation controller and you can access it from any controller as long as that controller has been pushed onto the navigation controllers stack. Much appreciated, I did not realise thats how it works.
fuzzygoat