loginview problem in tabbar application
i have a 3 t开发者_高级运维abbar 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.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.
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.
精彩评论