tags:

views:

67

answers:

1

HI I am developing an application where the NavigationBar at the top is hidden using this code:

- (void) viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

This means that once on this page there is no back Button to press to go back which means I have to create an IBAction which makes the view change back to the previous one.

I tried creating the IBAction which I use to go to the next page such as this one:

-(IBAction)switchToGettingHere:(id)sender
{
 if(self.gettingHereViewController == nil)
 {
  GettingHereViewController *gettingHere = [[GettingHereViewController alloc]
             initWithNibName:@"GettingHereView" bundle:[NSBundle mainBundle]];
  self.gettingHereViewController = gettingHere;
  [gettingHere release];
 } 
 [self.navigationController pushViewController:self.gettingHereViewController animated:YES];
}

but that didn't work. Any idea how to make a button perform the same as the standard back button?

+1  A: 

Why not just do (from the controller that doesn't have the navigation bar shown):

-(IBAction)switchToGettingHere:(id)sender
{
 [self.navigationController popViewControllerAnimated:YES];
}

This will pop the currently viewController off the stack and return you from whence you came.

chilitechno.com
super works great...
Matthew Pateman
matthew: please mark this an answered via the checkbox
iWasRobbed