Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dean1012

macrumors regular
Original poster
Jul 10, 2008
130
1
Hi all,

I have a tab bar based application in which each tab's view consists of a nav controller and a table view. Each tab works as a drill down.

The top level views (the views attached to each of the individual tabs) have viewWillAppear called.

However, when an item on a table view within one of those views is tapped, and subsequently another view is pushed onto the nav controller, viewWillAppear is NOT called.

No matter what I do I cannot figure out why. Any suggestions?
 
I am defining viewWillAppear correctly.

I will check to see if [self navigationController] is null or not but I doubt it is. I use this elsewhere in the same file and it works beautifully.
 
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.
 
help with same problem

I am defining viewWillAppear correctly.

I will check to see if [self navigationController] is null or not but I doubt it is. I use this elsewhere in the same file and it works beautifully.

I've *sorta* solved my problem but I am still having two remaining issues.

can you please tell how did you fix that problem because I have the same one, My viewWillAppear is getting executed but whenever I tried to use self.navigationController to dismiss the view nothing happen, so I guess for some reason self.navigationController is not existing yet, because if I use it somewhere else it dismisses the view

Thank You!!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.