more info
I've *sorta* solved my problem but I am still having two remaining issues.
First, i'll give a quick background of my setup to give you (hopefully) an exact idea of what i'm seeing.
I have a tab bar based application with 4 tabs. Each tab contains a navigation controller and table view; each tab operates as a separate drill down. Each tab has 3 drill down levels. The first two are table views and of course the third is a detail view.
I need viewWillAppear to be called whenever any of those 3 drill down levels will be displayed so I can update the data for that view if needed.
My original problem was that viewWillAppear was not being called at all. After some online research, I discovered that this is because the navigation controller for each tab needs to have received the viewWillAppear delegate itself before any subviews will receive it. The solution was to place a viewWillAppear method call in each of the 3 view controllers.
To quickly recap the background before I explain my problems,
1) tab bar app with 4 tabs
2) Each tab is separate drill down with 3 levels
3) Each drill down level has its own view controller
4) each tab effectively has 3 view controllers that relate to it
For purposes of my problem, we will take just one of the tabs (once it is solved for one tab it will be solved for all tabs).
For both problems, assume the following:
1) The top level of the drill down is the view controller displayed when the tab is selected
2) The top level of the drill down is viewWillAppearA
3) The second level of the drill down is viewWillAppearB
4) The detail view of the drill down is viewWillAppearC
Problem 1:
When I tap on the tab, the first view controller is displayed and viewWillAppearA is placed in the console as expected.
When I drill down to the second level, the second view controller is displayed and viewWillAppearB is placed on the console as expected.
When I drill down to the detail view, the third view controller is displayed and viewWillAppearC is placed on the console as expected.
When I drill back up to the second level, the second view controller is displayed and viewWillAppearB is placed on the console as expected.
Now here is the problem, when I drill back up to the top level, the first view controller is displayed but viewWillAppearA is NOT placed on the console as expected.
viewWillAppearA only gets called when the tab is selected not when the nav bar controller switches back to the top view.
Why is this?
Problem 2:
The second problem is pretty much like the first. I have an "i" at the top in my nav bar. when it is tapped, I use the app delegate to access the tabBarController and push a modal view ("about") to the screen.
If the user is on the 2nd level of the drill down and uses that modal button then closes the about view, they will receive two viewWillAppear. viewWillAppearB and viewWillAppearA, in that order.
And if they are on the detail level view and close it, they receive viewWillAppearC and viewWillAppearA, in that order.
Ideally, when the modal view is closed, only one viewWillAppear will be called; the delegate for the view that actually will appear.