…euphoria of life !!!

iPhone Dev: UINavigationController and viewWillAppear

leave a comment »

I recently came across a problem while developing and application that has UINavigationController inside a UITabBarController. When i tried to go back in the navigation menu that viewWillAppear or viewDidAppear function of the parent view was not firing up. I searched the net for the solution but was none were clear. So if you are facing a problem like this then try out the following solution.

1. When calling the next view always call the viewWillAppear before pushing the view in the view hierarchy.

    NextView *next = [[NextView alloc] init];
    [next viewWillAppear:YES];    // (or NO)
    [self.navigationcontroller pushViewController:next animated:YES];

2. When you press the back button and you want to call the viewWillAppear of the previous parent view do the following

    [[self.navigationController.viewControllers objectAtIndex:2] viewWillAppear:YES];
    [self.navigationController popViewControllerAnimated:YES];

Cheers !!


Written by tarangp

May 20, 2010 at 1:30 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: