views:

945

answers:

3

I currently have a TableView inside a NavigationController where when a item is selected the following code is ran:

DetailViewController *DetailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];

[self.navigationController pushViewController:DetailViewController animated:YES];
[DetailViewController release];
DetailViewController = nil;

This loads up my detail view, however my question is this... How can I call the backbutton on the navigation controller without pressing it? Or how can set it back to the table view (which is what the backbutton does)?

Thanks for any help :)

+4  A: 

You can call the popViewController method:

[self.navigationController popViewControllerAnimated:YES];
Philippe Leybaert
spank yew, just what I was after :)
ing0
A: 

This was a lifesaver post but now I have to call

[self.navigationController popViewControllerAnimated:YES];

from a tabbar item I've managed to do it from - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if ([viewController.tabBarItem.title isEqualToString:@"LIST"]) { [self.navigationController popViewControllerAnimated:YES]; } } on a sparate VC but now have the Tabbar on the RootViewController and can't access the navigationController.

Any ideas appreciated. I'm sure it's just syntax!

geo
A: 

hmmm, never mind, probably should push b4 popping....

geo