如何为iPhone应用程序添加注销功能? [英] How to add a logout feature to an iPhone app?

查看:112
本文介绍了如何为iPhone应用程序添加注销功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下布局的应用程序:

I've an app with this layout:

打开应用程序时,您会看到一个登录屏幕.登录后,您会看到一个带有3个标签的标签栏. (loginview在选项卡的appdelegate中与presentModalView一起显示).

When you open the app you see a login screen. You log in and you see a tabbar with 3 tabs. (The loginview is displayed with a presentModalView in the appdelegate of tabbar).

在第三个标签中,有一个注销按钮.我想要在按下注销按钮时删除应用程序的NSUserDefaults并再次显示loginview.而且,如果再次登录,登录屏幕就会消失,您会看到标签栏的第一个标签.

In the third tab there is a logout button. I want when logout button is pressed the app delete NSUserDefaults and shows the loginview again. And if you login again the login screen disappear and you see the first tab of the tabbar.

我该怎么做?

推荐答案

执行以下操作,

  1. 将登录视图放置在第一个视图控制器中.

  1. Place your login view in first view controller.

将标签栏控制器放置在第二个视图控制器中.

Place your tabbar controller in second view controller.

将第二个viewcontroller实例存储在appDelegate中(将用于导航).

Store the second viewcontroller instance in appDelegate (this will be used for navigation).

现在,当按下注销按钮时,使用存储的实例导航您的视图.

Now when the logout button is pressed,use the stored instance navigate your view.

这篇关于如何为iPhone应用程序添加注销功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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