iPhone Dev: UINavigationController and viewWillAppear

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];

你可能感兴趣的:(controller)