I have a set of five UINavigationControllers in a UITabBarController. The problem is that only some of the UINavigationControllers are having viewWillAppear: called in their respective UITableViewControllers.
My current set up is:
(Everything is created programmatically)
|
tabBarController
(UITabBarController)
|
---------------------------------------- ...etc...
| |
tempNavController tempNavController <--- Secondary NavContr
(UINavigationController) (UINavigationController) Not subclassed
| |
scheduleViewController currentViewController
(UITableViewController) (UITableViewController)
| |
...more UITableViewControllers...
Only some of the UITableViewControllers are calling viewWillAppear and viewDidAppear, and the ones that do, are not calling it for each way the view can appear. Some only call it when the I push to the view, some only when I pop to the view, and some only when I switch the tab to the view.
What would be causing the issue to only appear in some UITableViewControllers and not all of them? and why only in some of the ways the view can appear? All of the tabs and tables are set up in the same manner.
EDIT: Here is the code I use to set the tabs up:
- (void)viewDidLoad
{
//Setup of two of the tabs
//Create navigation controller and root view for each tab
//Current Comps
CurrentCompsViewController *tempCurrentCompsViewController = [[CurrentCompsViewController alloc] init];
[tempCurrentCompsViewController setAProgram:self.currentProgram];
self.currentCompsviewcontroller = [[UINavigationController alloc] initWithRootViewController:tempCurrentCompsViewController];
//Comp List
CompetitionListViewController *tempCompListViewController = [[CompetitionListViewController alloc] init];
[tempCompListViewController setAProgram:self.currentProgram];
self.competitionListViewController = [[UINavigationController alloc] initWithRootViewController:tempCompListViewController];
//Create and add tabBarItems
UITabBarItem *compListITem = [[UITabBarItem alloc] initWithTitle:@"Competitions" image:[UIImage imageNamed:@"CompsIcon.png"] tag:6];
[self.competitionListViewController setTabBarItem:compListITem];
UITabBarItem *curentItem = [[UITabBarItem alloc] initWithTitle:@"Current Comps." image:[UIImage imageNamed:@"CurrentIcon.png"] tag:7];
[self.currentCompsviewcontroller setTabBarItem:curentItem];
//Add everything to tab array, and sort tabs... etc...
}
I don’t override anything to do with selecting items in the tab view and do not subclass the navigation controllers at the root of each tab.
Turns out I forgot to call “[super viewWillAppear:animated]” in viewWillAppear:, viewDidLoad, and viewDidAppear:.
Always call back to the super class when you can.