views:

175

answers:

2

i have a 3 tabbar in my app. in my Appdelegate i have a reference to loginview where i am popingup loginview if user is not logged in.here is method.

 - (void)LoginView
{
loginView = [[[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil] autorelease]; 
UINavigationController* nav = (UINavigationController*)[tabBarController.viewControllers objectAtIndex:0]; 
loginView.navC = nav; [nav presentModalViewController:loginView animated:YES];
}

3rd tabbar is a settings view and i have a signout button there. at first time i can see correct user name,but as soon as i click sign out i am calling same method shown above using app delegate. logview gets popedup correctly and if i signin as different user it still show previous user name (because 3rd tabbar view is already loaded) so my question is
1)which is the best place to put loginview
2)how do i reset the app w/o restarting it after signout
i hope my question is clear. or i am willing to give more details.
thanks.
Update: basically i want to unload all view on signout and start from the beginning.

A: 

Better method would be to create a public changeLoginName: method on your settings controller, and call that method from the login view when the user is logged in. You can access that view through your tab bar, if you don't keep pointers to it anywhere else.

chpwn
thanks chpwn, but my problem is not just only name, the problem is what if i have other setting, even those should get change. and i have a 2nb tabbar as shopping cart. that should get change. right now it feels like loginview poped out and on click it gone though it updates some data but tabbar status stays as it is. do this description make sense?
Nnp
Then do a -reload method on everything that needs to get reloaded, and then call that on all your tabs.
chpwn
thanks chpwn. where do you want me to call 'reload' from signout button click or from signin button click?
Nnp
Probably, both.
chpwn
A: 

something which worked for me, and i hope this is proper way to doing.here is what i did.

NSArray *vc= tabBarController.viewControllers;
for (int i = 0; i < [vc count]; i++) {
    UINavigationController *nc = [vc objectAtIndex:i];
    if (nc == tabBarController.selectedViewController) {
        continue;
    }
    [nc popToRootViewControllerAnimated:NO];
}

i hope this unloads all the view from memory and force them to load again when tabbar is getting switched.let me know if this is not good way.

Nnp