如何为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.