views:

206

answers:

2

How to reset a uinavigationview to display the root controller when user clicks back to it in a tab bar app

Hey,

Just wondering how I would do this. I have the navcontroller in my delegate along with the tabbar controller and Any time the user clicks to another tab I want the rootview on the navigation controller to be shown if and when they click back the the tab that contains the uinavcontroller.

Does this make sense?

Nick

+1  A: 

Hi Nick.

[self.navigationController popToRootViewControllerAnimated:YES];

Or NO if you don't want it to animate.

This way all the views that were cached are still there, i.e. you don't "remove/release" all the views above the root view, unless the navigationController deems it necessary.

I hope this was what You were looking for..

RickiG
ok, just wondering where I trigger that, like how do I hook that into happening every time a user hits the particular tab view button on the tab bar that contains the uinavcontroller and stack? Thanks for your time.
nickthedude
Hi NickThere is a UITabBar delegate method you must implement for the tabbar to work. This is:- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)itemIt is a bit hard without seeing your code or knowing if you did it in interface builder or programmed it yourself. However, the method above gets called when a user taps the tabbar, so from there you can see which tabbar was tapped (UIBarItem) and from that you need to access the correct navigationController.Describe how you did the setup or post some of the code and I'll help you get it "popping" :)
RickiG
that makes sense I'll try to impliment that tonite. I think it should work.
nickthedude
so i couldnt get the didselectitem thing to work so I put the poptorootviewcontroller in the other tab bar views in the viewDidAppear method and it works like a champ. not sure how optimised it is but heck it works. thanks for the help!
nickthedude
+1  A: 

Hi Nick, your question is bit confusing. Please be some more informative so that we can get the exact problem you are facing…

Manjunath

Manjunath