views:

150

answers:

0

Having a simple Navigation Controller in place (starting the Navigation Based Application project) I created a new View with a XIB file.

on my HomeViewController (Home screen with all options as UIButton's I have:

@implementation HomeViewController

-(IBAction) optionChoosed:(UIButton *)button
{
    NSString *msg = [NSString stringWithFormat:@"Button: %d", button.tag];
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Hi" message:msg delegate:nil cancelButtonTitle:@"Go away" otherButtonTitles:nil];

    switch (button.tag) {
        case 13:
            // Simple Search
            [self loadSimpleSearch]; break;

        default:
            [alert show];           
            break;
    }
    [alert release];
}

-(void)loadSimpleSearch
{
    SimpleSearchViewController *controller = 
        [[SimpleSearchViewController alloc] initWithNibName:@"SimpleSearchViewController" bundle:nil];

    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

witch works great!

it Pushes the View into the front of the stack!

Now, because in my 2nd view SimpleSearchViewController I have self.title = @"myTitle"; I get the Title in the NavigationBar as well the back button (as I have the same setting on the HomeViewController)

I thought that the NavigationViewController would handle the pop of the current view, but it does not.

What do I have to do, to pop the SimpleSearchViewController?

Where do I use [self.navigationController popViewControllerAnimated:YES];

as the view continues there, and ViewDidUnload is never called.

My idea was that this should be handle in the first ViewController, the HomeViewController but I have no idea what is the method I should hook to, and I read the documentation and I can't figure it out :-/

Any help is greatly appreciated, thank you.

HomeViewController

alt text

SimpleSearchViewController

alt text

SimpleSearchViewController after pressing the Back button

alt text