标签栏应用程序中的登录视图问题

发布于 2024-08-17 04:37:56 字数 690 浏览 3 评论 0原文

我的应用程序中有一个 3 个选项卡栏。在我的 Appdelegate 中,我引用了登录视图,如果用户未登录,我将弹出登录视图。这是方法。

 - (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];
}

第三个选项卡是一个设置视图,我在那里有一个注销按钮。 第一次我可以看到正确的用户名,但是一旦我单击注销,我就会使用应用程序委托调用上面显示的相同方法。 logview 正确弹出,如果我以不同用户身份登录,它仍然显示以前的用户名(因为第三个选项卡栏视图已加载) 所以我的问题是
1)哪个是放置loginview的最佳位置
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北城半夏 2024-08-24 04:37:56

更好的方法是在设置控制器上创建一个公共的changeLoginName:方法,并在用户登录时从登录视图调用该方法。如果您不保留指向该视图的指针,则可以通过选项卡栏访问该视图其他任何地方。

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.

偏闹i 2024-08-24 04:37:56

对我有用的东西,我希望这是正确的做法。这就是我所做的。

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];
}

我希望这会从内存中卸载所有视图,并在切换选项卡栏时强制它们再次加载。请告诉我这是否不是好方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文