如何从iPhone应用程序注销并重新定向到登录页面? [英] How to Logout from an iPhone application and re-direct it to login page?

查看:66
本文介绍了如何从iPhone应用程序注销并重新定向到登录页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个tabBar应用程序,在该应用程序中我将登录页面预设为modalviewcontroller.稍后从页面登录后,我将显示TabBar.在选项卡之一中,我有我的LogOut View控制器,我想在其中注销并依次将应用程序重定向到登录页面.我需要删除所有加载的数据,然后在再次登录时使用输入的数据重新登录.我进行了很多搜索,但找不到任何帮助.有人可以帮我实现该功能吗?

I am developing a tabBar application where i am preseting the login page as a modalviewcontroller. Later after logging from the page, i am displaying the TabBar. In one of the Tab i have my LogOut View controller where i want to logout and inturn re-direct the application to the login page. I need to remove all the loaded data and then re-Login with the entered data when i re-Login again. I have searched a lot but not able to find any help on this. Can someone please help me in how to implement this functionality?

推荐答案

如果将登录视图显示为modelview,则没有问题.您可以在用户成功注销后再次执行此操作.只需再次显示即可显示登录页面.

if you are displaying login view as modelview, then no problem. you can do this again when your user successfully login out. just show the login page by presenting it again.

但是我的建议是,您应该以应用程序的根视图进行登录,并签入应用程序委托,以确保如果用户已经登录,请参考应用程序的主页,否则请参考登录页面.在注销按钮上,jst弹出以登录视图控制器.这是根视图控制器

but my suggestion is that you should make the login as root view of your app and check in app delegate that if user is already logged in then refer to your main page of app else refer to the login page. and at the logout button, jst pop to login view controller. which is root view controller

if([[[DataModel sharedDataModel] getValueForKey:USER_SESSION_ID]!= nil) { objLoginController = [[LoginController alloc] initWithNibName:@"LoginController" bundle:nil];

if([[DataModel sharedDataModel] getValueForKey:USER_SESSION_ID]!=nil) { objLoginController=[[LoginController alloc] initWithNibName:@"LoginController" bundle:nil];

    UINavigationController *temp=[[UINavigationController alloc] initWithRootViewController:objLoginController];
    self.mNavigationController=temp;

    [temp release];
    [objLoginController release];
    objLoginController = nil;


    if(objHomeController==nil)
    {
        objHomeController=[[HomeController alloc] initWithNibName:@"HomeController" bundle:nil];
    }

    [self.mNavigationController pushViewController:objHomeController animated:NO];

    [objHomeController release];
    objHomeController=nil;

    [mNavigationController setDelegate:self];
    mNavigationController.navigationBar.hidden=TRUE;
    [self.view addSubview:mNavigationController.view];
}
else
{
    objLoginController=[[LoginController alloc] initWithNibName:@"LoginController" bundle:nil];

    UINavigationController *temp=[[UINavigationController alloc] initWithRootViewController:objLoginController];
    self.mNavigationController=temp;

    [temp release];
    [objLoginController release];
    objLoginController = nil;

    [mNavigationController setDelegate:self];
    //mNavigationController.navigationBar.hidden=TRUE;
    //[mNavigationController setNavigationBarHidden:NO animated:YES];
    [self.view addSubview:self.mNavigationController.view];
}

这篇关于如何从iPhone应用程序注销并重新定向到登录页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆