views:

27

answers:

2

I have a tabBar controller. Tapping the active tab, by default, calls popToRootViewController on that tab's navigation controller. That is what I want, but I also need to do some customization when this happens. The view controller in question has a nav controller, but is not a subclass of UINavigationController. How can I listen for when popToRootViewController occurs and take some action?

A: 

You can put you code inside the method – tabBarController:didSelectViewController: of the UITabBarController delegate, or maybe inside the UIViewController's - viewWillAppear:animated: method.

asandroq
A: 

You can use UINavigationControllerDelegate's method:

– navigationController:didShowViewController:animated:

and check if the shown controller is the controller you want.

Hopes this helps

(I remember using this in iOS 2.x and it was a little bit buggy, I wonder if is ok now. It should be since it's 4 already)

nacho4d
This works, kind of. The only problem is that this method gets called when you first display the root view controller. I'd like to only take action if popToRootViewController happened.
sol
I haven't tried but UINavigationBarDelegate's methods should work also: navigationBar:didPopItem: for example
nacho4d